Because Python 2.4 doesn't have collections.defaultdict,
and because we are barely using the power of defaultdict
(we can replace both instances with dict.get(value)),
remove it.
... | ... |
@@ -8,7 +8,6 @@ from stat import ST_SIZE |
8 | 8 |
from logging import debug, info, warning, error |
9 | 9 |
from Utils import getTextFromXml, getTreeFromXml, formatSize, unicodise, calculateChecksum, parseNodes |
10 | 10 |
from Exceptions import S3UploadError |
11 |
-from collections import defaultdict |
|
12 | 11 |
|
13 | 12 |
class MultiPartUpload(object): |
14 | 13 |
|
... | ... |
@@ -28,7 +27,7 @@ class MultiPartUpload(object): |
28 | 28 |
multipart_response = self.s3.list_multipart(uri, upload_id) |
29 | 29 |
tree = getTreeFromXml(multipart_response['data']) |
30 | 30 |
|
31 |
- parts = defaultdict(lambda: None) |
|
31 |
+ parts = dict() |
|
32 | 32 |
for elem in parseNodes(tree): |
33 | 33 |
try: |
34 | 34 |
parts[int(elem['PartNumber'])] = {'checksum': elem['ETag'], 'size': elem['Size']} |
... | ... |
@@ -93,7 +92,7 @@ class MultiPartUpload(object): |
93 | 93 |
else: |
94 | 94 |
debug("MultiPart: Uploading from %s" % (self.file.name)) |
95 | 95 |
|
96 |
- remote_statuses = defaultdict(lambda: None) |
|
96 |
+ remote_statuses = dict() |
|
97 | 97 |
if self.s3.config.put_continue: |
98 | 98 |
remote_statuses = self.get_parts_information(self.uri, self.upload_id) |
99 | 99 |
|
... | ... |
@@ -109,7 +108,7 @@ class MultiPartUpload(object): |
109 | 109 |
'extra' : "[part %d of %d, %s]" % (seq, nr_parts, "%d%sB" % formatSize(current_chunk_size, human_readable = True)) |
110 | 110 |
} |
111 | 111 |
try: |
112 |
- self.upload_part(seq, offset, current_chunk_size, labels, remote_status = remote_statuses[seq]) |
|
112 |
+ self.upload_part(seq, offset, current_chunk_size, labels, remote_status = remote_statuses.get(seq)) |
|
113 | 113 |
except: |
114 | 114 |
error(u"\nUpload of '%s' part %d failed. Use\n %s abortmp %s %s\nto abort the upload, or\n %s --upload-id %s put ...\nto continue the upload." |
115 | 115 |
% (self.file.name, seq, sys.argv[0], self.uri, self.upload_id, sys.argv[0], self.upload_id)) |
... | ... |
@@ -128,7 +127,7 @@ class MultiPartUpload(object): |
128 | 128 |
if len(buffer) == 0: # EOF |
129 | 129 |
break |
130 | 130 |
try: |
131 |
- self.upload_part(seq, offset, current_chunk_size, labels, buffer, remote_status = remote_statuses[seq]) |
|
131 |
+ self.upload_part(seq, offset, current_chunk_size, labels, buffer, remote_status = remote_statuses.get(seq)) |
|
132 | 132 |
except: |
133 | 133 |
error(u"\nUpload of '%s' part %d failed. Use\n %s abortmp %s %s\nto abort, or\n %s --upload-id %s put ...\nto continue the upload." |
134 | 134 |
% (self.file.name, seq, self.uri, sys.argv[0], self.upload_id, sys.argv[0], self.upload_id)) |