summaryrefslogtreecommitdiffstats
path: root/pyload/config
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-20 02:21:11 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-20 02:21:11 +0100
commit9cef773c96f48f31d0c021578ab9bc47e9b3acdc (patch)
tree8b701dea430a55ef17d818436d2f973fb3a1b6a1 /pyload/config
parentConvert tabs to 4-whitespaces (diff)
downloadpyload-9cef773c96f48f31d0c021578ab9bc47e9b3acdc.tar.xz
Use utils encode/decode
Diffstat (limited to 'pyload/config')
-rw-r--r--pyload/config/Parser.py19
1 files changed, 5 insertions, 14 deletions
diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py
index 7a1709400..33f048150 100644
--- a/pyload/config/Parser.py
+++ b/pyload/config/Parser.py
@@ -6,7 +6,7 @@ from os.path import exists, join
from shutil import copy
from traceback import print_exc
-from utils import chmod
+from utils import chmod, encode, decode
CONF_VERSION = 1
@@ -227,7 +227,7 @@ class ConfigParser:
try:
f.write('\t%s %s : "%s" = %s' % (data["type"], option, data["desc"], value))
except UnicodeEncodeError:
- f.write('\t%s %s : "%s" = %s' % (data["type"], option, data["desc"], value.encode("utf8")))
+ f.write('\t%s %s : "%s" = %s' % (data["type"], option, data["desc"], encode(value))
def cast(self, typ, value):
"""cast value to given format"""
@@ -243,10 +243,7 @@ class ConfigParser:
if not ":" in value: value += ":00"
return value
elif typ in ("str", "file", "folder"):
- try:
- return value.encode("utf8")
- except:
- return value
+ return encode(value)
else:
return value
@@ -266,10 +263,7 @@ class ConfigParser:
def get(self, section, option):
"""get value"""
value = self.config[section][option]["value"]
- try:
- value = value.decode("utf-8")
- finally:
- return value
+ return decode(value)
def set(self, section, option, value):
"""set value"""
@@ -282,10 +276,7 @@ class ConfigParser:
def getPlugin(self, plugin, option):
"""gets a value for a plugin"""
value = self.plugin[plugin][option]["value"]
- try:
- value = value.decode("utf-8")
- finally:
- return str(value)
+ return encode(value)
def setPlugin(self, plugin, option, value):
"""sets a value for a plugin"""