1. mickael9
  2. gett-cli

Commits

mickael9  committed 5b5ceef

Fix humanize() returning None when nbytes = 0

  • Participants
  • Parent commits 82459e2
  • Branches default

Comments (0)

Files changed (1)

File scripts/gett

View file
  • Ignore whitespace
 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),