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

Ville Skyttä ville.skytta at iki.fi
Mon Jan 18 22:23:33 UTC 2010


On Monday 18 January 2010, James Antill wrote:
> ---
>  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)

I'm having some trouble understanding what this fixes.  You mentioned '1111 
vs. 11111 ("1.1 k" vs. "11 k")' earlier, but I don't see any alignment issues 
with these without (or with) the patch.  With the '' => ' ' change, I suppose 
things will be already ok because the size column is right aligned in the 
output.  Do you have a simple yum command I could use to test with, or could 
you copy/paste some output before/after the patch that shows the effect of 
this change?

The patch hunk below seems ok, but it tests format_number() only and not 
listTransaction() so it can't be used to test the above.

> @@ -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"
> 



More information about the Yum-devel mailing list