--- dump_walker.py
+++ dump_walker.py
@@ -6,6 +6,12 @@
if n.nodeType == xml.dom.minidom.Node.ELEMENT_NODE:
yield n
+def getAttr(x, name):
+ for i in range(x.attributes.length):
+ if x.attributes.item(i) == name:
+ return x.attributes.item(i).value
+ return None
+
def childElementsName(x, name):
for n in childElements(x):
if n.nodeName == name:
@@ -26,8 +32,8 @@
return ""
def _parseCustomButton(object, c, prefix = None):
- if c.attributes.has_key("cid-icon"):
- cid = c.attributes["cid-icon"].value
+ cid = getAttr(c, "cid-icon")
+ if None != cid:
buttonName = c.attributes["text"].value.replace("/", "_")
if prefix:
prefix = prefix + "-"
@@ -36,8 +42,8 @@
object._addCid(cid, "%sicon-%s.tar%s" % (prefix, buttonName, _ext(cid)))
def _addCidIfAttribute(object, x, attributeName, fileName):
- if x.attributes.has_key(attributeName):
- cid = x.attributes[attributeName].value
+ cid = getAttr(x, attributeName)
+ if None != cid:
object._addCid(cid, fileName + _ext(cid))
class PleskObject(object):
@@ -58,8 +64,8 @@
class Client(PleskObject):
def __init__(self, x):
PleskObject.__init__(self, "client", x.attributes["name"].value)
- if x.attributes.has_key("cid-skeleton"):
- cid = x.attributes["cid-skeleton"].value
+ cid = getAttr(x, "cid-skeleton")
+ if None != cid:
self._addCid(cid, "skeleton.tar" + _ext(cid))
for c in childElementsName(x, "custom-button"):
_parseCustomButton(self, c)