summaryrefslogtreecommitdiffstats
path: root/module/Utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/Utils.py')
-rw-r--r--module/Utils.py15
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)