def xmlAttributesToConfig(self, node, config): try: i = 0 #if node.attributes.length < len(config.dict())-1: #self.error = "project attributes missing" #raise AttributeError while i < node.attributes.length: item = node.attributes.item(i) key = item.name.encode("utf-8") try: val = eval(item.nodeValue) except (NameError, SyntaxError): val = item.nodeValue.encode("utf-8") try: print "config[%s].setValue(%s)" % (key, val) config.dict()[key].setValue(val) except (KeyError): self.error = "unknown attribute '%s'" % (key) print "KeyError", self.error raise AttributeError i += 1 except AttributeError: self.error += (" XML attribute error '%s'") % node.toxml() return False
def xmlAttributesToConfig(self, node, config): try: i = 0 # if node.attributes.length < len(config.dict())-1: #self.error = "project attributes missing" #raise AttributeError while i < node.attributes.length: item = node.attributes.item(i) key = item.name.encode("utf-8") try: val = eval(item.nodeValue) except (NameError, SyntaxError): val = item.nodeValue.encode("utf-8") try: print("[DVDBurn] config[%s].setValue(%s)" % (key, val)) config.dict()[key].setValue(val) except (KeyError): self.error = "unknown attribute '%s'" % (key) print("[DVDBurn] KeyError", self.error) raise AttributeError i += 1 except AttributeError: self.error += (" XML attribute error '%s'") % node.toxml() return False