diff options
author | spoob <spoob@gmx.de> | 2010-01-09 17:15:45 +0100 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2010-01-09 17:15:45 +0100 |
commit | a0fec87a584a029854fc7eec4773c1074bf21b80 (patch) | |
tree | 6362f3c26e9d32d109941eb9c1ca9ec8feb70388 | |
parent | Updated XML Config Changes (diff) | |
download | pyload-a0fec87a584a029854fc7eec4773c1074bf21b80.tar.xz |
Hooks can set Attributes
-rw-r--r-- | module/XMLConfigParser.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/module/XMLConfigParser.py b/module/XMLConfigParser.py index 8105eb929..5f58c834b 100644 --- a/module/XMLConfigParser.py +++ b/module/XMLConfigParser.py @@ -103,7 +103,7 @@ class XMLConfigParser(): def getConfig(self): return self.config - def set(self, section, option, value): + def set(self, section, data, value): root = self.root replace = False sectionNode = False @@ -113,13 +113,14 @@ class XMLConfigParser(): sectionNode = node for opt in node.childNodes: if opt.nodeType == opt.ELEMENT_NODE: - if option == opt.tagName: + if data["option"] == opt.tagName: replace = opt + self._setAttributes(node, data) text = self.xml.createTextNode(str(value)) if replace: - replace.replaceChild(text, replace.firstChild) + replace.replaceChild(text, replace.firstChild) else: - newNode = self.xml.createElement(option) + newNode = self.xml.createElement(data["option"]) newNode.appendChild(text) if sectionNode: sectionNode.appendChild(newNode) @@ -127,8 +128,19 @@ class XMLConfigParser(): newSection = self.xml.createElement(section) newSection.appendChild(newNode) root.appendChild(newSection) + self._setAttributes(newSection, data) self.saveData() self.loadData() + + def _setAttributes(self, node, data): + node.setAttribute("name", node.tagName) + option = node.getElementsByTagName(data["option"])[0] + option.setAttribute("name", data["name"]) + option.setAttribute("type", data["type"]) + try: + option.setAttribute("input", data["input"]) + except: + pass def getType(self, section, option): try: |