From 15841561a8e5650d88e4af477b8e4f8f96a81253 Mon Sep 17 00:00:00 2001 From: mkaay Date: Sat, 26 Dec 2009 21:17:45 +0100 Subject: pluginconfig now in xml --- .hgignore | 2 ++ icons/gui/refresh_small.png | Bin 0 -> 821 bytes icons/gui/remove_small.png | Bin 0 -> 287 bytes module/Plugin.py | 23 ++++++++++++----------- module/XMLConfigParser.py | 5 ++++- module/config/plugin_default.xml | 39 +++++++++++++++++++++++++++++++++++++++ pluginconfig | 29 ----------------------------- 7 files changed, 57 insertions(+), 41 deletions(-) create mode 100644 icons/gui/refresh_small.png create mode 100644 icons/gui/remove_small.png create mode 100644 module/config/plugin_default.xml delete mode 100644 pluginconfig diff --git a/.hgignore b/.hgignore index 1af47aa3b..10afb8d80 100644 --- a/.hgignore +++ b/.hgignore @@ -14,6 +14,7 @@ Plugins/DLC.py failed_links.txt module/config/gui.xml module/config/core.xml +module/config/plugin.xml links.txt module/links.pkl module/cookies.txt @@ -21,3 +22,4 @@ ssl.crt ssl.key cert.pem module/web/pyload.db +webserver.pid diff --git a/icons/gui/refresh_small.png b/icons/gui/refresh_small.png new file mode 100644 index 000000000..1ffd18d97 Binary files /dev/null and b/icons/gui/refresh_small.png differ diff --git a/icons/gui/remove_small.png b/icons/gui/remove_small.png new file mode 100644 index 000000000..bf99763e8 Binary files /dev/null and b/icons/gui/remove_small.png differ diff --git a/module/Plugin.py b/module/Plugin.py index 7e6ca4e35..9390cbe07 100644 --- a/module/Plugin.py +++ b/module/Plugin.py @@ -20,15 +20,16 @@ import ConfigParser import logging import re -from os.path import exists +from os.path import exists, join from module.network.Request import Request +from module.XMLConfigParser import XMLConfigParser class Plugin(): def __init__(self, parent): - self.parser = ConfigParser.SafeConfigParser() + self.configparser = XMLConfigParser(join("module","config","plugin.xml"), join("module","config","plugin_default.xml")) self.config = {} props = {} props['name'] = "BasePlugin" @@ -112,19 +113,19 @@ class Plugin(): self.req.download(url, location) def set_config(self): - pass + for k, v in self.config: + self.configparser.set(self.props['name'], k, v) def get_config(self, value): - self.parser.read("pluginconfig") - return self.parser.get(self.props['name'], value) + self.configparser.loadData() + return self.configparser.get(self.props['name'], value) def read_config(self): - self.parser.read("pluginconfig") - - if self.parser.has_section(self.props['name']): - for option in self.parser.options(self.props['name']): - self.config[option] = self.parser.get(self.props['name'], option, raw=True) - self.config[option] = False if self.config[option].lower() == 'false' else self.config[option] + self.configparser.loadData() + try: + self.config = self.configparser.getConfig()[self.props['name']] + except: + pass def init_ocr(self): modul = __import__("module.captcha." + self.props['name'], fromlist=['captcha']) diff --git a/module/XMLConfigParser.py b/module/XMLConfigParser.py index 51741fdfd..eedc00b67 100644 --- a/module/XMLConfigParser.py +++ b/module/XMLConfigParser.py @@ -59,7 +59,10 @@ class XMLConfigParser(): config[section] = {} for opt in node.childNodes: if opt.nodeType == opt.ELEMENT_NODE: - config[section][opt.tagName] = format(opt.firstChild.data) + try: + config[section][opt.tagName] = format(opt.firstChild.data) + except: + config[section][opt.tagName] = "" self.config = config def get(self, section, option, default=None): diff --git a/module/config/plugin_default.xml b/module/config/plugin_default.xml new file mode 100644 index 000000000..01c0e7ed6 --- /dev/null +++ b/module/config/plugin_default.xml @@ -0,0 +1,39 @@ + + + + + + False + + + + + False + + + + + False + + + + + False + + + + + True + + + + False + + diff --git a/pluginconfig b/pluginconfig deleted file mode 100644 index c0fdd3d10..000000000 --- a/pluginconfig +++ /dev/null @@ -1,29 +0,0 @@ -[RapidshareCom] -#select server, empty for automatic, else Cogent, Deutsche Telekom, Level(3), Level(3) #2, GlobalCrossing, Level(3) #3, Teleglobe, GlobalCrossing #2, TeliaSonera #2, Teleglobe #2, TeliaSonera #3, TeliaSonera -server = "" -premium = False -username = namehere -password = passhere - -[NetloadIn] -premium = False -username = namehere -password = passhere - -[UploadedTo] -premium = False -username = namehere -password = passhere - -[ShareonlineBiz] -premium = False -username = namehere -password = passhere - -[YoutubeCom] -high_quality = True - -[YoutubeChannel] -#type False for no limitation -max_videos = False - -- cgit v1.2.3