From 3e87db92c439a4b8378a165f42a01ba142b56a5c Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 17 Apr 2015 00:50:31 +0200 Subject: Spare code cosmetics (1) --- pyload/config/Parser.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'pyload/config/Parser.py') diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py index bad512a5f..ed81d041c 100644 --- a/pyload/config/Parser.py +++ b/pyload/config/Parser.py @@ -91,8 +91,8 @@ class ConfigParser(object): homeconf = self.parseConfig("pyload.conf") if "username" in homeconf["remote"]: if "password" in homeconf["remote"]: - self.oldRemoteData = {"username": homeconf["remote"]["username"]["value"], - "password": homeconf["remote"]["username"]["value"]} + self.oldRemoteData = {"username": homeconf["remote"]["username"]['value'], + "password": homeconf["remote"]["username"]['value']} del homeconf["remote"]["password"] del homeconf["remote"]["username"] self.updateValues(homeconf, self.config) @@ -159,7 +159,7 @@ class ConfigParser(object): typ, none, option = content.strip().rpartition(" ") value = value.strip() - typ = typ.strip() + typ = typ.strip() if value.startswith("["): if value.endswith("]"): @@ -195,7 +195,7 @@ class ConfigParser(object): continue if option in dest[section]: - dest[section][option]["value"] = config[section][option]["value"] + dest[section][option]['value'] = config[section][option]['value'] # else: # dest[section][option] = config[section][option] @@ -216,20 +216,20 @@ class ConfigParser(object): for option, data in config[section].iteritems(): if option in ("desc", "outline"): continue - if isinstance(data["value"], list): + if isinstance(data['value'], list): value = "[ \n" - for x in data["value"]: + for x in data['value']: value += "\t\t" + str(x) + ",\n" value += "\t\t]\n" else: - if isinstance(data["value"], basestring): - value = data["value"] + "\n" + if isinstance(data['value'], basestring): + value = data['value'] + "\n" else: - value = str(data["value"]) + "\n" + value = str(data['value']) + "\n" try: - f.write('\t%s %s : "%s" = %s' % (data["type"], option, data["desc"], value)) + 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"], encode(value))) + f.write('\t%s %s : "%s" = %s' % (data['type'], option, data["desc"], encode(value))) def cast(self, typ, value): @@ -266,33 +266,31 @@ class ConfigParser(object): def get(self, section, option): """get value""" - value = self.config[section][option]["value"] + value = self.config[section][option]['value'] return decode(value) def set(self, section, option, value): """set value""" - - value = self.cast(self.config[section][option]["type"], value) - - self.config[section][option]["value"] = value + value = self.cast(self.config[section][option]['type'], value) + self.config[section][option]['value'] = value self.save() def getPlugin(self, plugin, option): """gets a value for a plugin""" - value = self.plugin[plugin][option]["value"] + value = self.plugin[plugin][option]['value'] return encode(value) def setPlugin(self, plugin, option, value): """sets a value for a plugin""" - value = self.cast(self.plugin[plugin][option]["type"], value) + value = self.cast(self.plugin[plugin][option]['type'], value) if self.pluginCB: self.pluginCB(plugin, option, value) - self.plugin[plugin][option]["value"] = value + self.plugin[plugin][option]['value'] = value self.save() @@ -319,7 +317,7 @@ class ConfigParser(object): for item in config: if item[0] in conf: - conf[item[0]]["type"] = item[1] + conf[item[0]]['type'] = item[1] conf[item[0]]["desc"] = item[2] else: conf[item[0]] = { -- cgit v1.2.3 From 20226f8cc5889efbefa61209e1adf6184d42cd00 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 17 Apr 2015 01:21:41 +0200 Subject: Spare code cosmetics (3) --- pyload/config/Parser.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'pyload/config/Parser.py') diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py index ed81d041c..d2ec9bde2 100644 --- a/pyload/config/Parser.py +++ b/pyload/config/Parser.py @@ -89,12 +89,12 @@ class ConfigParser(object): try: homeconf = self.parseConfig("pyload.conf") - if "username" in homeconf["remote"]: - if "password" in homeconf["remote"]: - self.oldRemoteData = {"username": homeconf["remote"]["username"]['value'], - "password": homeconf["remote"]["username"]['value']} - del homeconf["remote"]["password"] - del homeconf["remote"]["username"] + if "username" in homeconf['remote']: + if "password" in homeconf['remote']: + self.oldRemoteData = {"username": homeconf['remote']['username']['value'], + "password": homeconf['remote']['username']['value']} + del homeconf['remote']['password'] + del homeconf['remote']['username'] self.updateValues(homeconf, self.config) except Exception: print "Config Warning" @@ -211,7 +211,7 @@ class ConfigParser(object): chmod(filename, 0600) f.write("version: %i \n" % CONF_VERSION) for section in config.iterkeys(): - f.write('\n%s - "%s":\n' % (section, config[section]["desc"])) + f.write('\n%s - "%s":\n' % (section, config[section]['desc'])) for option, data in config[section].iteritems(): if option in ("desc", "outline"): continue @@ -227,9 +227,9 @@ class ConfigParser(object): else: value = str(data['value']) + "\n" try: - f.write('\t%s %s : "%s" = %s' % (data['type'], option, data["desc"], value)) + 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"], encode(value))) + f.write('\t%s %s : "%s" = %s' % (data['type'], option, data['desc'], encode(value))) def cast(self, typ, value): @@ -313,12 +313,12 @@ class ConfigParser(object): self.plugin[name] = conf else: conf = self.plugin[name] - conf["outline"] = outline + conf['outline'] = outline for item in config: if item[0] in conf: conf[item[0]]['type'] = item[1] - conf[item[0]]["desc"] = item[2] + conf[item[0]]['desc'] = item[2] else: conf[item[0]] = { "desc": item[2], -- cgit v1.2.3 From bb5a115533711fd8bb87f53cb32ff7342137208d Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 18 Apr 2015 00:29:55 +0200 Subject: Spare code cosmetics (5) --- pyload/config/Parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pyload/config/Parser.py') diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py index d2ec9bde2..b26af6202 100644 --- a/pyload/config/Parser.py +++ b/pyload/config/Parser.py @@ -214,7 +214,8 @@ class ConfigParser(object): f.write('\n%s - "%s":\n' % (section, config[section]['desc'])) for option, data in config[section].iteritems(): - if option in ("desc", "outline"): continue + if option in ("desc", "outline"): + continue if isinstance(data['value'], list): value = "[ \n" -- cgit v1.2.3