Gitlab Community Edition Instance

Commit 89e90b4d authored by mhellka's avatar mhellka
Browse files

Strip ".0" from hbytes() output

parent fdd9aff3
...@@ -15,11 +15,11 @@ def walk_up(start): ...@@ -15,11 +15,11 @@ def walk_up(start):
current_dir = parent current_dir = parent
def hbytes(n, units=None): def hbytes(n, units=None, div=1024.0):
for unit in units or ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"): for unit in units or ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"):
if abs(n) < 1024.0: if abs(n) < div:
return "{:.1f} {}".format(n, unit) return "{:.1f}{}".format(n, unit).replace(".0", "")
n /= 1024.0 n /= div
raise AssertionError("Number out of range") raise AssertionError("Number out of range")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment