diff options
author | Josh Smith <qinusty@gmail.com> | 2018-09-14 14:33:05 +0100 |
---|---|---|
committer | Qinusty <jrsmith9822@gmail.com> | 2018-09-19 09:44:04 +0000 |
commit | bbe4151dfbf84cc910f00d2535778b479372b98e (patch) | |
tree | be97cd4058dd250b07342c927c5650416da8f6c3 | |
parent | 72b5902157316e173de2eec5b3a2772283eec3c7 (diff) | |
download | buildstream-bbe4151dfbf84cc910f00d2535778b479372b98e.tar.gz |
utils: Fix _pretty_size() for sizes > 1024T
-rw-r--r-- | buildstream/utils.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/buildstream/utils.py b/buildstream/utils.py index 60211f35b..d5db64a80 100644 --- a/buildstream/utils.py +++ b/buildstream/utils.py @@ -631,7 +631,7 @@ def _parse_size(size, volume): # _pretty_size() # -# Converts a number of bytes into a string representation in KB, MB, GB, TB +# Converts a number of bytes into a string representation in KiB, MiB, GiB, TiB # represented as K, M, G, T etc. # # Args: @@ -643,10 +643,11 @@ def _parse_size(size, volume): def _pretty_size(size, dec_places=0): psize = size unit = 'B' - for unit in ('B', 'K', 'M', 'G', 'T'): + units = ('B', 'K', 'M', 'G', 'T') + for unit in units: if psize < 1024: break - else: + elif unit != units[-1]: psize /= 1024 return "{size:g}{unit}".format(size=round(psize, dec_places), unit=unit) |