Merge from custcol trunk

This commit is contained in:
Charles Haley 2010-05-16 19:36:42 +01:00
commit 07db04903b

View File

@ -232,12 +232,10 @@ def info_dialog(parent, title, msg, det_msg='', show=False):
def human_readable(size): def human_readable(size):
""" Convert a size in bytes into a human readable form """ """ Convert a size in bytes into a human readable form """
divisor, suffix = 1, "B" divisor, suffix = 1, "B"
if size < 1024*1024: for i, candidate in enumerate(('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB')):
divisor, suffix = 1024., "KB" if size < 1024**(i+1):
elif size < 1024*1024*1024: divisor, suffix = 1024**(i), candidate
divisor, suffix = 1024*1024, "MB" break
elif size < 1024*1024*1024*1024:
divisor, suffix = 1024*1024*1024, "GB"
size = str(float(size)/divisor) size = str(float(size)/divisor)
if size.find(".") > -1: if size.find(".") > -1:
size = size[:size.find(".")+2] size = size[:size.find(".")+2]