summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/Utils.py9
-rw-r--r--module/plugins/Plugin.py4
2 files changed, 11 insertions, 2 deletions
diff --git a/module/Utils.py b/module/Utils.py
index 3d344a147..fee1dee0f 100644
--- a/module/Utils.py
+++ b/module/Utils.py
@@ -21,6 +21,13 @@ def decode(string):
except:
return string
+def removeChars(string, repl):
+ """ removes all chars in repl from string"""
+ if type(string) == str:
+ return string.translate(None, repl)
+ elif type(string) == unicode:
+ return string.translate(dict([(ord(s), None) for s in repl]))
+
def save_join(*args):
""" joins a path, encoding aware """
paths = []
@@ -104,3 +111,5 @@ def parseFileSize(string): #returns bytes
if __name__ == "__main__":
print freeSpace(".")
+
+ print replace("ab'cdgdsf''ds'", "'ghd")
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 5607b8331..482bb0e45 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -38,7 +38,7 @@ if os.name != "nt":
from itertools import islice
-from module.utils import save_join, decode
+from module.utils import save_join, decode, removeChars
def chunks(iterable, size):
it = iter(iterable)
@@ -351,7 +351,7 @@ class Plugin(object):
name = self.pyfile.name
if os_name == 'nt':
#delete illegal characters
- name = name.translate(None, '/\\?%*:|"<>')
+ name = removeChars(name, '/\\?%*:|"<>')
filename = save_join(location, name)
try: