diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-01 04:00:43 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-01 04:00:43 +0200 |
commit | 6fc9c8453f6e83b85d5aae008e504593ad355318 (patch) | |
tree | 9dc1f4494579195493883b57b28422cd7326f55a /pyload/utils/__init__.py | |
parent | Merge branch 'stable' into 0.4.10 (diff) | |
download | pyload-6fc9c8453f6e83b85d5aae008e504593ad355318.tar.xz |
Use bitmath lib to formatSize
Diffstat (limited to 'pyload/utils/__init__.py')
-rw-r--r-- | pyload/utils/__init__.py | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/pyload/utils/__init__.py b/pyload/utils/__init__.py index 3d26983b5..da84fe51c 100644 --- a/pyload/utils/__init__.py +++ b/pyload/utils/__init__.py @@ -3,6 +3,7 @@ """ Store all useful functions here """ +import bitmath import os import re import sys @@ -91,7 +92,6 @@ def save_join(*args): if sys.getfilesystemencoding().startswith('ANSI'): - def fs_encode(string): return safe_filename(encode(string)) @@ -131,13 +131,7 @@ def compare_time(start, end): def formatSize(size): """formats size of bytes""" - size = int(size) - steps = 0 - sizes = ("B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB") - while size > 1000: - size /= 1024.0 - steps += 1 - return "%.2f %s" % (size, sizes[steps]) + return bitmath.Byte(int(size)).best_prefix() def formatSpeed(speed): @@ -213,7 +207,6 @@ def parseFileSize(string, unit=None): #: returns bytes def lock(func): - def new(*args): # print "Handler: %s args: %s" % (func, args[1:]) args[0].lock.acquire() |