* write fonksiyonlarini biraz gelistir ama onemli bir bug var, yariyor tagpath'i yazarken
This commit is contained in:
@@ -16,12 +16,6 @@ import dependency
|
|||||||
##gibi bir test edip nerelere extend edecek ama gorelim
|
##gibi bir test edip nerelere extend edecek ama gorelim
|
||||||
##lutfen. daha hic calismadi bile. :/
|
##lutfen. daha hic calismadi bile. :/
|
||||||
|
|
||||||
##alternatif olarak bunu muhtemelen ops diye bir module'e
|
|
||||||
##tasimak
|
|
||||||
##daha iyi olabilir. install/remove/upgrade islemlerinin
|
|
||||||
##oldugu, ya da boyle ayrik kalabilir, ne ne kadar tutuyor
|
|
||||||
##daha belli degil...
|
|
||||||
|
|
||||||
class InstallError(Exception):
|
class InstallError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -96,4 +96,5 @@ class SpecFile(XmlFile):
|
|||||||
"""Write PSPEC file"""
|
"""Write PSPEC file"""
|
||||||
self.newDOM()
|
self.newDOM()
|
||||||
self.addNodeText("Source/Name", self.source.name)
|
self.addNodeText("Source/Name", self.source.name)
|
||||||
|
archiveNode = self.addNode("Source/Archive")
|
||||||
self.writexml(filename)
|
self.writexml(filename)
|
||||||
|
|||||||
+12
-7
@@ -43,6 +43,7 @@ def getNode(node, tagpath):
|
|||||||
"""returns the *first* matching node for given tag path."""
|
"""returns the *first* matching node for given tag path."""
|
||||||
|
|
||||||
tags = tagpath.split('/')
|
tags = tagpath.split('/')
|
||||||
|
assert len(tags)>0
|
||||||
|
|
||||||
# iterative code to search for the path
|
# iterative code to search for the path
|
||||||
|
|
||||||
@@ -86,13 +87,18 @@ def getAllNodes(node, tagPath):
|
|||||||
return nodeList
|
return nodeList
|
||||||
|
|
||||||
|
|
||||||
def appendTagPath(dom, node, tagpath, child):
|
def appendTagPath(dom, node, tagpath, child = None):
|
||||||
"""append child at the end of a tag chain starting from node"""
|
"""append child at the end of a tag chain starting from node"""
|
||||||
for tag in tagpath[0:len(tagpath)-1]:
|
for tag in tagpath[0:len(tagpath)-1]:
|
||||||
node = node.appendChild(dom.createElement(tag))
|
node = node.appendChild(dom.createElement(tag))
|
||||||
node.appendChild(child)
|
if child:
|
||||||
|
return node.appendChild(child)
|
||||||
|
else:
|
||||||
|
return node.appendChild(dom.createElement(tag))
|
||||||
|
|
||||||
|
def addNode(dom, node, tagpath, newnode = None):
|
||||||
|
"""add a new node at the end of the tree"""
|
||||||
|
|
||||||
def addNode(dom, node, tagpath, newnode):
|
|
||||||
tags = tagpath.split('/')
|
tags = tagpath.split('/')
|
||||||
assert len(tags)>0
|
assert len(tags)>0
|
||||||
|
|
||||||
@@ -106,8 +112,7 @@ def addNode(dom, node, tagpath, newnode):
|
|||||||
|
|
||||||
if len(nodeList) == 0:
|
if len(nodeList) == 0:
|
||||||
print 'SIFIR'
|
print 'SIFIR'
|
||||||
appendTagPath(dom, node, tagpath, newnode)
|
return appendTagPath(dom, node, tagpath, newnode)
|
||||||
return
|
|
||||||
|
|
||||||
node = nodeList[0] # discard other matches
|
node = nodeList[0] # discard other matches
|
||||||
tags.pop(0)
|
tags.pop(0)
|
||||||
@@ -116,7 +121,7 @@ def addNode(dom, node, tagpath, newnode):
|
|||||||
nodeList = node.getElementsByTagName(tag)
|
nodeList = node.getElementsByTagName(tag)
|
||||||
if len(nodeList) == 0:
|
if len(nodeList) == 0:
|
||||||
tags = tag.insert(0)
|
tags = tag.insert(0)
|
||||||
appendTagPath(node, tags, newnode)
|
return appendTagPath(node, tags, newnode)
|
||||||
else:
|
else:
|
||||||
node = nodeList[0]
|
node = nodeList[0]
|
||||||
|
|
||||||
@@ -207,7 +212,7 @@ class XmlFile(object):
|
|||||||
|
|
||||||
# write helpers
|
# write helpers
|
||||||
|
|
||||||
def addNode(self, tagPath, newnode):
|
def addNode(self, tagPath, newnode = None):
|
||||||
self.verifyRootTag()
|
self.verifyRootTag()
|
||||||
return addNode(self.dom, self.dom.documentElement, tagPath, newnode)
|
return addNode(self.dom, self.dom.documentElement, tagPath, newnode)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user