Merge pull request #797 from AI0867/patch-1

Use standard unit symbols in format_bytes
This commit is contained in:
Philipp Hagemeister 2013-04-22 14:13:52 -07:00
commit 71f37e90ef

View File

@ -121,7 +121,7 @@ def format_bytes(bytes):
exponent = 0 exponent = 0
else: else:
exponent = int(math.log(bytes, 1024.0)) exponent = int(math.log(bytes, 1024.0))
suffix = 'bkMGTPEZY'[exponent] suffix = ['B','KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'][exponent]
converted = float(bytes) / float(1024 ** exponent) converted = float(bytes) / float(1024 ** exponent)
return '%.2f%s' % (converted, suffix) return '%.2f%s' % (converted, suffix)