From e42dabfa142ad8ae1f1029e5fc9f5aa4c428f514 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 16 Nov 2014 00:13:21 +0100 Subject: [ConfigParser] getPlugin return str --- pyload/config/Parser.py | 26 ++++++++++---------------- 1 file 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""" -- cgit v1.2.3