1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix 'format' method syntax to support Python 2.6 (Fixes #28198) (#28304)

Fixes #28198
Changed how string format method is used to support Python 2.6 syntax. By adding in positional arguments to braces in format method (e.g. {0}, {1}), Python 2.6 can support this module, without causing issues in newer versions of Python.

See ref for info on format differences w/ 2.6:
https://docs.python.org/2/library/string.html#format-string-syntax
This commit is contained in:
bonuscheese 2017-08-22 03:57:26 +10:00 committed by Sloane Hertel
parent 44f4294f5c
commit 7c366f5cbd

View file

@ -277,12 +277,12 @@ def calculate_multipart_etag(source_path, chunk_size=DEFAULT_CHUNK_SIZE):
md5s.append(hashlib.md5(data))
if len(md5s) == 1:
new_etag = '"{}"'.format(md5s[0].hexdigest())
new_etag = '"{0}"'.format(md5s[0].hexdigest())
else: # > 1
digests = b"".join(m.digest() for m in md5s)
new_md5 = hashlib.md5(digests)
new_etag = '"{}-{}"'.format(new_md5.hexdigest(), len(md5s))
new_etag = '"{0}-{1}"'.format(new_md5.hexdigest(), len(md5s))
return new_etag
@ -432,8 +432,8 @@ def filter_list(s3, bucket, s3filelist, strategy):
remote_size = entry['s3_head']['ContentLength']
entry['whytime'] = '{} / {}'.format(local_modified_epoch, remote_modified_epoch)
entry['whysize'] = '{} / {}'.format(local_size, remote_size)
entry['whytime'] = '{0} / {1}'.format(local_modified_epoch, remote_modified_epoch)
entry['whysize'] = '{0} / {1}'.format(local_size, remote_size)
if local_modified_epoch <= remote_modified_epoch or local_size == remote_size:
entry['skip_flag'] = True