summaryrefslogtreecommitdiff
path: root/keystoneclient/common
diff options
context:
space:
mode:
authorCedric Brandily <zzelle@gmail.com>2014-12-04 13:06:08 +0100
committerCedric Brandily <zzelle@gmail.com>2014-12-19 23:59:34 +0100
commit4350c176048b8d159d08b82b915e9544ac9dee6f (patch)
tree2e572f59b0469c4c1581584f0ade530bd489864f /keystoneclient/common
parentf8f81bb119b63b85f9a3f72ba81045e065b01cce (diff)
downloadpython-keystoneclient-4350c176048b8d159d08b82b915e9544ac9dee6f.tar.gz
Use textwrap instead of home made implementation
This change replaces a home made text wrapper by textwrap module. It is a non-functional change which is covered by existing tests. Closes-Bug: #1404402 Change-Id: I5cc4da61205f64b478366c29e6d7ff9929ad4d16
Diffstat (limited to 'keystoneclient/common')
-rw-r--r--keystoneclient/common/cms.py19
1 files changed, 5 insertions, 14 deletions
diff --git a/keystoneclient/common/cms.py b/keystoneclient/common/cms.py
index d49a0c5..19390f2 100644
--- a/keystoneclient/common/cms.py
+++ b/keystoneclient/common/cms.py
@@ -23,6 +23,7 @@ import base64
import errno
import hashlib
import logging
+import textwrap
import zlib
import six
@@ -227,20 +228,10 @@ def pkiz_verify(signed_text, signing_cert_file_name, ca_file_name):
def token_to_cms(signed_text):
copy_of_text = signed_text.replace('-', '/')
- formatted = '-----BEGIN CMS-----\n'
- line_length = 64
- while len(copy_of_text) > 0:
- if (len(copy_of_text) > line_length):
- formatted += copy_of_text[:line_length]
- copy_of_text = copy_of_text[line_length:]
- else:
- formatted += copy_of_text
- copy_of_text = ''
- formatted += '\n'
-
- formatted += '-----END CMS-----\n'
-
- return formatted
+ lines = ['-----BEGIN CMS-----']
+ lines += textwrap.wrap(copy_of_text, 64)
+ lines.append('-----END CMS-----\n')
+ return '\n'.join(lines)
def verify_token(token, signing_cert_file_name, ca_file_name):