diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-11-16 00:13:21 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-11-16 00:13:21 +0100 |
commit | e42dabfa142ad8ae1f1029e5fc9f5aa4c428f514 (patch) | |
tree | 14b7dace7eabc7374cf86ef495820fb4627e5a38 | |
parent | Update .gitignore (diff) | |
download | pyload-e42dabfa142ad8ae1f1029e5fc9f5aa4c428f514.tar.xz |
[ConfigParser] getPlugin return str
-rw-r--r-- | pyload/config/Parser.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py index faba6b191..7a1709400 100644 --- a/pyload/config/Parser.py +++ b/pyload/config/Parser.py @@ -220,7 +220,7 @@ class ConfigParser: value += "\t\t" + str(x) + ",\n" value += "\t\t]\n" else: - if type(data["value"]) in (str, unicode): + if isinstance(data["value"], basestring): value = data["value"] + "\n" else: value = str(data["value"]) + "\n" @@ -231,7 +231,7 @@ class ConfigParser: def cast(self, typ, value): """cast value to given format""" - if type(value) not in (str, unicode): + if not isinstance(value, basestring): return value elif typ == "int": @@ -265,14 +265,11 @@ class ConfigParser: def get(self, section, option): """get value""" - val = self.config[section][option]["value"] + value = self.config[section][option]["value"] try: - if type(val) in (str, unicode): - return val.decode("utf8") - else: - return val - except: - return val + value = value.decode("utf-8") + finally: + return value def set(self, section, option, value): """set value""" @@ -284,14 +281,11 @@ class ConfigParser: def getPlugin(self, plugin, option): """gets a value for a plugin""" - val = self.plugin[plugin][option]["value"] + value = self.plugin[plugin][option]["value"] try: - if type(val) in (str, unicode): - return val.decode("utf8") - else: - return val - except: - return val + value = value.decode("utf-8") + finally: + return str(value) def setPlugin(self, plugin, option, value): """sets a value for a plugin""" |