Merge "filesizeformat() does't consider the situation like float('inf')
"
This commit is contained in:
commit
22d907cb76
@ -51,6 +51,8 @@ def filesizeformat(bytes, filesize_number_format):
|
||||
return ungettext_lazy("%(size)d Byte",
|
||||
"%(size)d Bytes", 0) % {'size': 0}
|
||||
|
||||
if bytes == float('inf'):
|
||||
return _('Infinity')
|
||||
if bytes < units.Ki:
|
||||
bytes = int(bytes)
|
||||
return ungettext_lazy("%(size)d Byte",
|
||||
@ -63,7 +65,13 @@ def filesizeformat(bytes, filesize_number_format):
|
||||
return _("%s GB") % filesize_number_format(bytes / units.Gi)
|
||||
if bytes < units.Pi:
|
||||
return _("%s TB") % filesize_number_format(bytes / units.Ti)
|
||||
return _("%s PB") % filesize_number_format(bytes / units.Pi)
|
||||
if bytes < units.Ei:
|
||||
return _("%s PB") % filesize_number_format(bytes / units.Pi)
|
||||
if bytes < units.Zi:
|
||||
return _("%s EB") % filesize_number_format(bytes / units.Ei)
|
||||
if bytes < units.Yi:
|
||||
return _("%s ZB") % filesize_number_format(bytes / units.Zi)
|
||||
return _("%s YB") % filesize_number_format(bytes / units.Yi)
|
||||
|
||||
|
||||
def float_cast_filesizeformat(value, multiplier=1, format=int_format):
|
||||
|
Loading…
Reference in New Issue
Block a user