diff options
author | mkaay <mkaay@mkaay.de> | 2010-05-05 23:03:43 +0200 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-05-05 23:03:43 +0200 |
commit | 81508f295cffc40c479fe72f24bdf1dbbedf5d92 (patch) | |
tree | 0cb68f0a525d0ead0cd8130c3adad150c49b81a7 /module/XMLConfigParser.py | |
parent | megavideo.com plugin (diff) | |
download | pyload-81508f295cffc40c479fe72f24bdf1dbbedf5d92.tar.xz |
refactored plugins, new plugin manager
Diffstat (limited to 'module/XMLConfigParser.py')
-rw-r--r-- | module/XMLConfigParser.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/module/XMLConfigParser.py b/module/XMLConfigParser.py index 575dbd219..b691ecb8e 100644 --- a/module/XMLConfigParser.py +++ b/module/XMLConfigParser.py @@ -21,7 +21,7 @@ from os.path import exists from xml.dom.minidom import parse import re -from shutil import copy +from shutil import copy, move class XMLConfigParser(): def __init__(self, data, forceDefault=False, defaultFile=None): @@ -54,8 +54,12 @@ class XMLConfigParser(): with open(file, 'r') as fh: self.xml = parse(fh) if not self.xml.documentElement.getAttribute("version") == self.version: - print "Cant Update %s" % self.file - exit() #ok? + print _("Cant Update %s, your config version is outdated") % self.file + i = raw_input(_("backup old file and copy new one? [%s]/%s") % (_("yes")[0], _("no")[0])) + if i == "" or i == _("yes")[0]: + move(self.file, self.file.replace(".xml", "_backup.xml")) + self.loadData(self) + return self.root = self.xml.documentElement self._read_config() @@ -63,7 +67,7 @@ class XMLConfigParser(): try: copy(self.file_default, self.file) except: - print "%s not found" % self.file_default + print _("%s not found") % self.file_default exit() #ok? def saveData(self): @@ -215,7 +219,9 @@ class XMLConfigParser(): self.config[section] return True except: - return False + if self.forceDefault: + return False + return self.defaultParser.isValidSection(section) def checkInput(self, section, option, value): oinput = self.getInputValues(section, option) @@ -247,7 +253,7 @@ class Config(object): def __getitem__(self, key): if self.parser.isValidSection(key): return Section(self.parser, key) - raise Exception("invalid section") + raise Exception(_("invalid section")) def keys(self): return self.parser.config.keys() |