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
This commit is contained in:
@@ -23,6 +23,7 @@ import base64
|
|||||||
import errno
|
import errno
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
|
import textwrap
|
||||||
import zlib
|
import zlib
|
||||||
|
|
||||||
import six
|
import six
|
||||||
@@ -227,20 +228,10 @@ def pkiz_verify(signed_text, signing_cert_file_name, ca_file_name):
|
|||||||
def token_to_cms(signed_text):
|
def token_to_cms(signed_text):
|
||||||
copy_of_text = signed_text.replace('-', '/')
|
copy_of_text = signed_text.replace('-', '/')
|
||||||
|
|
||||||
formatted = '-----BEGIN CMS-----\n'
|
lines = ['-----BEGIN CMS-----']
|
||||||
line_length = 64
|
lines += textwrap.wrap(copy_of_text, 64)
|
||||||
while len(copy_of_text) > 0:
|
lines.append('-----END CMS-----\n')
|
||||||
if (len(copy_of_text) > line_length):
|
return '\n'.join(lines)
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def verify_token(token, signing_cert_file_name, ca_file_name):
|
def verify_token(token, signing_cert_file_name, ca_file_name):
|
||||||
|
Reference in New Issue
Block a user