Created
April 15, 2010 22:44
-
-
Save deleted/367764 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sizeof_human(numbytes): | |
''' Human-readable size strings ''' | |
if numbytes < 0: # urlretrieve passes -1 for totalsize if it can't get the filesize from the server | |
return '???' | |
for x in ['bytes','KB','MB','GB','TB','PB']: | |
if numbytes < 1024.0: | |
return "%3.2f%s" % (numbytes, x) | |
numbytes /= 1024.0 | |
else: | |
return "Exabytes!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment