Commit 2ed6bdd0 authored by Roland Denis's avatar Roland Denis

Fallback in storage unit formatter for high values

parent 225d0bf1
Pipeline #6576 passed with stages
in 2 minutes and 17 seconds
......@@ -27,11 +27,14 @@ def jinja2_format_storage(value, power=0, units=['o', 'Kio', 'Mio', 'Gio', 'Tio'
""" Format storage quantity with appropriate suffix """
# The old way
while value >= base:
while value >= base and power < len(units) - 1:
value /= base
power += 1
return f"{value:.3g} {units[power]}"
if value >= base:
return f"{round(value)} {units[power]}"
else:
return f"{value:.3g} {units[power]}"
# Extend default translator
......
Markdown is supported
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