diff options
author | Josh Smith <qinusty@gmail.com> | 2018-09-14 14:33:05 +0100 |
---|---|---|
committer | richardmaw-codethink <richard.maw@codethink.co.uk> | 2018-11-06 13:23:19 +0000 |
commit | 9a045080ac1e5c3554baccb566d06303ab9b2fbd (patch) | |
tree | a62b849c956be3a814576c73c17400cedbfd0f2c | |
parent | ec04446b58de7c04e587378c7086cff068fa8025 (diff) | |
download | buildstream-9a045080ac1e5c3554baccb566d06303ab9b2fbd.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 c116797bd..dc66f3e62 100644 --- a/buildstream/utils.py +++ b/buildstream/utils.py @@ -634,7 +634,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: @@ -646,10 +646,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) |