From 553e34ebfe891fe234abd722ceeba0809775a175 Mon Sep 17 00:00:00 2001
From: Tim Burke <tim.burke@gmail.com>
Date: Mon, 20 Sep 2021 12:33:16 -0700
Subject: [PATCH] Improve formatting for billions of objects

Change-Id: If8aa08c4c8c8ad6ca2c861602baf1eefa8642a8a
---
 swiftclient/shell.py    |  4 ++--
 test/unit/test_shell.py | 16 +++++++++-------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index 43950e6c..cf90ffcf 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -552,7 +552,7 @@ def st_list(parser, args, output_manager, return_parser=False):
                         datestamp = '????-??-?? ??:??:??'
                     if not options['totals']:
                         output_manager.print_msg(
-                            "%5s %s %s %s", count, byte_str,
+                            "%12s %s %s %s", count, byte_str,
                             datestamp, item_name)
                 else:    # list container contents
                     subdir = item.get('subdir')
@@ -584,7 +584,7 @@ def st_list(parser, args, output_manager, return_parser=False):
         if options['long'] or human:
             if not container:
                 output_manager.print_msg(
-                    "%5s %s", prt_bytes(total_count, True),
+                    "%12s %s", prt_bytes(total_count, True),
                     prt_bytes(total_bytes, human))
             else:
                 output_manager.print_msg(
diff --git a/test/unit/test_shell.py b/test/unit/test_shell.py
index 8c525d9a..84dd681e 100644
--- a/test/unit/test_shell.py
+++ b/test/unit/test_shell.py
@@ -475,9 +475,10 @@ class TestShell(unittest.TestCase):
                      mock.call(marker='container', prefix=None, headers={})]
             connection.return_value.get_account.assert_has_calls(calls)
 
-            self.assertEqual(output.out,
-                             '    0    0 1970-01-01 00:00:01 container\n'
-                             '    0    0\n')
+            self.assertEqual(
+                output.out,
+                '           0    0 1970-01-01 00:00:01 container\n'
+                '           0    0\n')
 
         # Now test again, this time without returning metadata
         connection.return_value.head_container.return_value = {}
@@ -495,9 +496,10 @@ class TestShell(unittest.TestCase):
                      mock.call(marker='container', prefix=None, headers={})]
             connection.return_value.get_account.assert_has_calls(calls)
 
-            self.assertEqual(output.out,
-                             '    0    0 ????-??-?? ??:??:?? container\n'
-                             '    0    0\n')
+            self.assertEqual(
+                output.out,
+                '           0    0 ????-??-?? ??:??:?? container\n'
+                '           0    0\n')
 
     def test_list_account_totals_error(self):
         # No --lh provided: expect info message about incorrect --totals use
@@ -523,7 +525,7 @@ class TestShell(unittest.TestCase):
             swiftclient.shell.main(argv)
             calls = [mock.call(marker='', prefix=None, headers={})]
             connection.return_value.get_account.assert_has_calls(calls)
-            self.assertEqual(output.out, '    6    3\n')
+            self.assertEqual(output.out, '           6    3\n')
 
     @mock.patch('swiftclient.service.Connection')
     def test_list_container(self, connection):