summaryrefslogtreecommitdiff
path: root/swiftclient
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2020-04-10 17:16:11 -0700
committerTim Burke <tim.burke@gmail.com>2020-04-10 17:16:15 -0700
commit9b0da49c0b337585e24825de2ad670a0798179ac (patch)
tree64c9884888f53609f91cc4eef8778bc53bb35547 /swiftclient
parent78edffa46c591fdc53f253b343e1ea144e24089d (diff)
downloadpython-swiftclient-9b0da49c0b337585e24825de2ad670a0798179ac.tar.gz
Improve `list --versions` output
Have `--versions` imply `--long` and add a new column for version_id. Also, have version-aware listings show all versions as "null" on old Swifts that don't support object versioning (or when object versioning is not enabled). Change-Id: I0e009bce2471d1c140ac9b83700591cb355fee3f
Diffstat (limited to 'swiftclient')
-rwxr-xr-xswiftclient/shell.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index 03a8fa6..1b34c08 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -534,7 +534,7 @@ def st_list(parser, args, output_manager, return_parser=False):
container = stats.get("container", None)
for item in stats["listing"]:
item_name = item.get('name')
- if not options['long'] and not human:
+ if not options['long'] and not human and not options['versions']:
output_manager.print_msg(item.get('name', item.get('subdir')))
else:
if not container: # listing containers
@@ -566,9 +566,16 @@ def st_list(parser, args, output_manager, return_parser=False):
date = xtime = ''
item_name = subdir
if not options['totals']:
- output_manager.print_msg(
- "%s %10s %8s %24s %s",
- byte_str, date, xtime, content_type, item_name)
+ if options['versions']:
+ output_manager.print_msg(
+ "%s %10s %8s %16s %24s %s",
+ byte_str, date, xtime,
+ item.get('version_id', 'null'),
+ content_type, item_name)
+ else:
+ output_manager.print_msg(
+ "%s %10s %8s %24s %s",
+ byte_str, date, xtime, content_type, item_name)
total_bytes += item_bytes
# report totals