[Yum-devel] [PATCH 2/2] Fix alignment of some package sizes in listTransaction. Add tests for format_number.

James Antill james at and.org
Mon Jan 18 20:58:08 UTC 2010


---
 output.py |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/output.py b/output.py
index 17ce582..f221129 100755
--- a/output.py
+++ b/output.py
@@ -921,7 +921,7 @@ class YumOutput:
             evr = po.printVer()
             repoid = po.ui_from_repo
             pkgsize = float(po.size)
-            size = self.format_number(pkgsize)
+            size = "%5s" % self.format_number(pkgsize)
 
             if a is None: # gpgkeys are weird
                 a = 'noarch'
@@ -1905,6 +1905,18 @@ def progressbar(current, total, name=None):
         
 
 if __name__ == "__main__":
+    if len(sys.argv) > 1 and sys.argv[1] == "format_number":
+        print ""
+        print " Doing format_number tests, right column should align"
+        print ""
+
+        x = YumOutput()
+        for i in (0, 0.0, 0.1, 1, 1.0, 1.1, 10, 11, 11.1, 100, 111.1,
+                  1000, 1111, 1024 * 2, 10000, 11111, 99999, 999999,
+                  10**19, 10**20, 10**35):
+            out = x.format_number(i)
+            print "%36s <%s> %s <%5s>" % (i, out, ' ' * (14 - len(out)), out)
+
     if len(sys.argv) > 1 and sys.argv[1] == "progress":
         print ""
         print " Doing progress, small name"
-- 
1.6.5.2



More information about the Yum-devel mailing list