summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-26 21:17:45 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-26 21:17:45 +0100
commit15841561a8e5650d88e4af477b8e4f8f96a81253 (patch)
treed1cbee2d936ed90fdf99df90b1bcec9b31e58257 /module
parentfixed view update (diff)
downloadpyload-15841561a8e5650d88e4af477b8e4f8f96a81253.tar.xz
pluginconfig now in xml
Diffstat (limited to 'module')
-rw-r--r--module/Plugin.py23
-rw-r--r--module/XMLConfigParser.py5
-rw-r--r--module/config/plugin_default.xml39
3 files changed, 55 insertions, 12 deletions
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 @@
+<config>
+ <RapidshareCom>
+ <!-- possible:
+ Cogent, Deutsche Telekom,
+ Level(3), Level(3) #2,
+ GlobalCrossing, Level(3) #3,
+ Teleglobe, GlobalCrossing #2,
+ TeliaSonera #2, Teleglobe #2,
+ TeliaSonera #3, TeliaSonera
+ -->
+ <!-- leave empty for autmomatic selection -->
+ <server></server>
+ <premium>False</premium>
+ <username></username>
+ <password></password>
+ </RapidshareCom>
+ <NetloadIn>
+ <premium>False</premium>
+ <username></username>
+ <password></password>
+ </NetloadIn>
+ <UploadedTo>
+ <premium>False</premium>
+ <username></username>
+ <password></password>
+ </UploadedTo>
+ <ShareonlineBiz>
+ <premium>False</premium>
+ <username></username>
+ <password></password>
+ </ShareonlineBiz>
+ <YoutubeCom>
+ <high_quality>True</high_quality>
+ </YoutubeCom>
+ <YoutubeChannel>
+ <!-- False for no limitation -->
+ <max_videos>False</max_videos>
+ </YoutubeChannel>
+</config>