mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 16:06:43 -06:00
humanize_speed: Only give one decimal number
a speed of 2048 would be rendered as "2.048 Mbps", where the decimal dot could be confused with a thousand separator. closes #10157
This commit is contained in:
parent
88d2fca2c6
commit
2fcb4afec3
@ -48,7 +48,7 @@ def humanize_speed(speed):
|
||||
"""
|
||||
Humanize speeds given in Kbps. Examples:
|
||||
|
||||
1544 => "1.544 Mbps"
|
||||
1544 => "1.6 Mbps"
|
||||
100000 => "100 Mbps"
|
||||
10000000 => "10 Gbps"
|
||||
"""
|
||||
@ -61,7 +61,7 @@ def humanize_speed(speed):
|
||||
elif speed >= 1000 and speed % 1000 == 0:
|
||||
return '{} Mbps'.format(int(speed / 1000))
|
||||
elif speed >= 1000:
|
||||
return '{} Mbps'.format(float(speed) / 1000)
|
||||
return '{:.1f} Mbps'.format(float(speed) / 1000)
|
||||
else:
|
||||
return '{} Kbps'.format(speed)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user