Commits

mickael9 committed 5b5ceef

Fix humanize() returning None when nbytes = 0

Comments (0)

Files changed (1)

 user.refresh()
 
 def humanize(nbytes):
-    for (exp, unit) in ((9, 'GB'), (6, 'MB'), (3, 'KB'), (0, 'B')):
+    for (exp, unit) in ((9, 'GB'), (6, 'MB'), (3, 'KB')):
        if nbytes >= 10**exp:
            return '%.2f %s' % (nbytes / 10**exp, unit)
 
+    return '%.2f B' % nbytes
+
+
 print('Storage used : %s out of %s (%d %%)' % (
         humanize(user.storage_used),
         humanize(user.storage_limit),