git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@371 830e0280-6d2a-0410-9c65-932aecc39d9d
Michal Ludvig authored on 2009/02/12 09:00:12... | ... |
@@ -1,5 +1,10 @@ |
1 | 1 |
2009-02-12 Michal Ludvig <michal@logix.cz> |
2 | 2 |
|
3 |
+ * s3cmd: Added --list-md5 for 'ls' command. |
|
4 |
+ * S3/Config.py: New setting list_md5 |
|
5 |
+ |
|
6 |
+2009-02-12 Michal Ludvig <michal@logix.cz> |
|
7 |
+ |
|
3 | 8 |
* s3cmd: Set Content-Length header for requests with 'body'. |
4 | 9 |
* s3cmd: And send it for requests with no body as well... |
5 | 10 |
|
... | ... |
@@ -118,18 +118,28 @@ def subcmd_bucket_list(s3, uri): |
118 | 118 |
else: |
119 | 119 |
raise |
120 | 120 |
|
121 |
+ if cfg.list_md5: |
|
122 |
+ format_string = u"%(timestamp)16s %(size)9s%(coeff)1s %(md5)32s %(uri)s" |
|
123 |
+ else: |
|
124 |
+ format_string = u"%(timestamp)16s %(size)9s%(coeff)1s %(uri)s" |
|
125 |
+ |
|
121 | 126 |
for prefix in response['common_prefixes']: |
122 |
- output(u"%s %s" % ( |
|
123 |
- "DIR".rjust(26), |
|
124 |
- uri.compose_uri(bucket, prefix["Prefix"]))) |
|
127 |
+ output(format_string % { |
|
128 |
+ "timestamp": "", |
|
129 |
+ "size": "DIR", |
|
130 |
+ "coeff": "", |
|
131 |
+ "md5": "", |
|
132 |
+ "uri": uri.compose_uri(bucket, prefix["Prefix"])}) |
|
125 | 133 |
|
126 | 134 |
for object in response["list"]: |
127 | 135 |
size, size_coeff = formatSize(object["Size"], Config().human_readable_sizes) |
128 |
- output(u"%s %s%s %s" % ( |
|
129 |
- formatDateTime(object["LastModified"]), |
|
130 |
- str(size).rjust(8), size_coeff.ljust(1), |
|
131 |
- uri.compose_uri(bucket, object["Key"]), |
|
132 |
- )) |
|
136 |
+ output(format_string % { |
|
137 |
+ "timestamp": formatDateTime(object["LastModified"]), |
|
138 |
+ "size" : str(size), |
|
139 |
+ "coeff": size_coeff, |
|
140 |
+ "md5" : object['ETag'].strip('"'), |
|
141 |
+ "uri": uri.compose_uri(bucket, object["Key"]), |
|
142 |
+ }) |
|
133 | 143 |
|
134 | 144 |
def cmd_bucket_create(args): |
135 | 145 |
s3 = S3(Config()) |
... | ... |
@@ -1367,6 +1377,7 @@ def main(): |
1367 | 1367 |
|
1368 | 1368 |
optparser.add_option( "--encoding", dest="encoding", metavar="ENCODING", help="Override autodetected terminal and filesystem encoding (character set). Autodetected: %s" % preferred_encoding) |
1369 | 1369 |
|
1370 |
+ optparser.add_option( "--list-md5", dest="list_md5", action="store_true", help="Include MD5 sums in bucket listings (only for 'ls' command).") |
|
1370 | 1371 |
optparser.add_option("-H", "--human-readable-sizes", dest="human_readable_sizes", action="store_true", help="Print sizes in human readable form.") |
1371 | 1372 |
|
1372 | 1373 |
optparser.add_option( "--progress", dest="progress_meter", action="store_true", help="Display progress meter (default on TTY).") |