| |
@@ -24,13 +24,15 @@
|
| |
units = ('KiB', 'MiB', 'GiB', 'TiB')
|
| |
size = float(size)
|
| |
chosen = 'B'
|
| |
+ prec = 0
|
| |
for unit in units:
|
| |
if size > 1024:
|
| |
+ prec = 2
|
| |
size = size / 1024
|
| |
chosen = unit
|
| |
else:
|
| |
break
|
| |
- return '%.2f %s' % (size, chosen)
|
| |
+ return '{0:.{1}f} {2}'.format(size, prec, chosen)
|
| |
|
| |
|
| |
def to_utf8(text):
|
| |
@@ -455,7 +457,7 @@
|
| |
result.append("Summary: %s" % i["summary"])
|
| |
if not shorten:
|
| |
result.append("RPMs: %s" % " ".join(sorted(i["rpms"])))
|
| |
- result.append("Size: %s bytes" % i["size"])
|
| |
+ result.append("Size: %s" % formatsize(i["size"]))
|
| |
result.append("")
|
| |
result.append("")
|
| |
|
| |
@@ -465,7 +467,7 @@
|
| |
if not shorten:
|
| |
result.append("Summary: %s" % i["summary"])
|
| |
result.append("RPMs: %s" % " ".join(sorted(i["rpms"])))
|
| |
- result.append("Size: %s bytes" % i["size"])
|
| |
+ result.append("Size: %s" % formatsize(i["size"]))
|
| |
result.append("")
|
| |
result.append("")
|
| |
|
| |
@@ -481,8 +483,8 @@
|
| |
if i["dropped_rpms"]:
|
| |
result.append("Dropped RPMs: %s" % " ".join(i["dropped_rpms"]))
|
| |
if not shorten:
|
| |
- result.append("Size: %s bytes" % i["size"])
|
| |
- result.append("Size change: %s bytes" % i["size_change"])
|
| |
+ result.append("Size: %s" % formatsize(i["size"]))
|
| |
+ result.append("Size change: %s" % formatsize(i["size_change"]))
|
| |
if i["changelog"]:
|
| |
result.append("Changelog:")
|
| |
for entry in i["changelog"]:
|
| |
@@ -504,8 +506,8 @@
|
| |
if i["dropped_rpms"]:
|
| |
result.append("Dropped RPMs: %s" % " ".join(i["dropped_rpms"]))
|
| |
if not shorten:
|
| |
- result.append("Size: %s bytes" % i["size"])
|
| |
- result.append("Size change: %s bytes" % i["size_change"])
|
| |
+ result.append("Size: %s" % formatsize(i["size"]))
|
| |
+ result.append("Size change: %s" % formatsize(i["size_change"]))
|
| |
if i["changelog"]:
|
| |
result.append("Changelog:")
|
| |
for entry in i["changelog"]:
|
| |
Even size change for a package should be formatted with bigger unit than bytes. The formatting function is also updated to not print decimal places when the unit used is actually B (as at that point there can never be anything else than .00).
Fixes: https://pagure.io/compose-utils/issue/50