diff options
author | ardi69 <armin@diedering.de> | 2015-04-18 14:08:18 +0200 |
---|---|---|
committer | ardi69 <armin@diedering.de> | 2015-04-18 14:08:18 +0200 |
commit | 6e8f84e1dc06cff6fa9387559992f555182c1774 (patch) | |
tree | 476600f9896fae029880e4049eb4c5e6021b202d /pyload/config | |
parent | fix: config cast (diff) | |
parent | Spare code cosmetics (5) (diff) | |
download | pyload-6e8f84e1dc06cff6fa9387559992f555182c1774.tar.xz |
Merge pull request #3 from vuolter/0.4.10
merge vuolter HEAD
Diffstat (limited to 'pyload/config')
-rw-r--r-- | pyload/config/Parser.py | 55 | ||||
-rw-r--r-- | pyload/config/default.conf | 14 |
2 files changed, 34 insertions, 35 deletions
diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py index bad512a5f..b26af6202 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" @@ -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] @@ -211,25 +211,26 @@ 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 + 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 +267,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() @@ -315,12 +314,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]]['type'] = item[1] + conf[item[0]]['desc'] = item[2] else: conf[item[0]] = { "desc": item[2], diff --git a/pyload/config/default.conf b/pyload/config/default.conf index 453c40b4b..e07b92f68 100644 --- a/pyload/config/default.conf +++ b/pyload/config/default.conf @@ -21,13 +21,13 @@ webui - "Web User Interface": str prefix : "Path Prefix" = None log - "Log": - bool file_log : "File Log" = True - folder log_folder : "Folder" = Logs - int log_count : "Count" = 5 - int log_size : "Size in kb" = 100 - bool log_rotate : "Log Rotate" = True - bool color_console : "Colored console" = True - label;full color_template : "Color template" = label + bool file_log : "File Log" = True + folder log_folder : "Folder" = Logs + int log_count : "Count" = 5 + int log_size : "Size in kb" = 100 + bool log_rotate : "Log Rotate" = True + bool color_console : "Colored console" = True + label;line;mixed color_template : "Color template" = mixed general - "General": en;de;fr;it;es;nl;sv;ru;pl;cs;sr;pt_BR language : "Language" = en |