diff options
author | 2011-12-23 21:40:22 +0100 | |
---|---|---|
committer | 2011-12-23 21:40:22 +0100 | |
commit | 8da44b430b957b25e74dff63829d4198a52e7a0b (patch) | |
tree | f20fc60db6e7d9a93fe3ca60cd68a6e32b536fc6 /module/Utils.py | |
parent | oron version increase (diff) | |
parent | little fixes (diff) | |
download | pyload-8da44b430b957b25e74dff63829d4198a52e7a0b.tar.xz |
merge hotfixes in
Diffstat (limited to 'module/Utils.py')
-rw-r--r-- | module/Utils.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/module/Utils.py b/module/Utils.py index 8748b7693..86fd67558 100644 --- a/module/Utils.py +++ b/module/Utils.py @@ -8,6 +8,7 @@ import time import re from os.path import join from string import maketrans +from itertools import islice from htmlentitydefs import name2codepoint def chmod(*args): @@ -20,7 +21,10 @@ def chmod(*args): def decode(string): """ decode string with utf if possible """ try: - return string.decode("utf8", "replace") + if type(string) == str: + return string.decode("utf8", "replace") + else: + return string except: return string @@ -100,6 +104,8 @@ def formatSpeed(speed): def freeSpace(folder): + folder = fs_encode(folder) + if os.name == "nt": import ctypes @@ -168,6 +174,13 @@ def lock(func): return new +def chunks(iterable, size): + it = iter(iterable) + item = list(islice(it, size)) + while item: + yield item + item = list(islice(it, size)) + def fixup(m): text = m.group(0) |