Added exception handling to data.nice_size().

This commit is contained in:
Greg Von Kuster
2008-03-05 15:52:29 +00:00
parent 87cecc8f26
commit 9863127799
+4
View File
@@ -280,6 +280,10 @@ def nice_size(size):
'95.4 Mb'
"""
words = [ 'bytes', 'Kb', 'Mb', 'Gb' ]
try:
size = float( size )
except:
return '??? bytes'
for ind, word in enumerate(words):
step = 1024 ** (ind + 1)
if step > size: