frobar: Fix bytes sizes
This commit is contained in:
parent
8edb670486
commit
91df3670f6
|
@ -30,18 +30,19 @@ log = logging.getLogger()
|
||||||
# PulseaudioProvider and MpdProvider)
|
# PulseaudioProvider and MpdProvider)
|
||||||
|
|
||||||
|
|
||||||
def humanSize(num: int) -> str:
|
def humanSize(numi: int) -> str:
|
||||||
"""
|
"""
|
||||||
Returns a string of width 3+3
|
Returns a string of width 3+3
|
||||||
"""
|
"""
|
||||||
|
num = float(numi)
|
||||||
for unit in ("B ", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB"):
|
for unit in ("B ", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB"):
|
||||||
if abs(num) < 1000:
|
if abs(num) < 1000:
|
||||||
if num >= 10:
|
if num >= 10:
|
||||||
return "{:3d}{}".format(int(num), unit)
|
return "{:3d}{}".format(int(num), unit)
|
||||||
else:
|
else:
|
||||||
return "{:.1f}{}".format(num, unit)
|
return "{:.1f}{}".format(num, unit)
|
||||||
num //= 1024
|
num /= 1024
|
||||||
return "{:d}YiB".format(num)
|
return "{:d}YiB".format(numi)
|
||||||
|
|
||||||
|
|
||||||
def randomColor(seed: int | bytes = 0) -> str:
|
def randomColor(seed: int | bytes = 0) -> str:
|
||||||
|
|
Loading…
Reference in a new issue