diff --git a/doc/pisi.lyx b/doc/pisi.lyx index 024475cb..1afa84dd 100644 --- a/doc/pisi.lyx +++ b/doc/pisi.lyx @@ -831,6 +831,9 @@ files.xml dosyalar pisi-files.dtd \emph default dosyasında tanımlanmıştır. +\layout Standard + +Bunlarin da acaba attribute seklinde olmasi daha mi dogru olur? -- Eray \layout Subsection PSPEC Deposu diff --git a/pisi/files.py b/pisi/files.py index 8fa27f9f..ddc44365 100644 --- a/pisi/files.py +++ b/pisi/files.py @@ -3,12 +3,21 @@ class FileInfo: + def __init__(self, node): self.path = getNodeText(getNode(node, "Path")) self.type = getNodeText(getNode(node, "Type")) self.size = int(getNodeText(getNode(node, "Size"))) self.md5Sum = getNodeText(getNode(node, "MD5Sum")) + def elt(self, dom): + ## FIXME: looking for the clean way to do it + elt = dom.createElement() + elt.appendChild(dom.createTextNode(path)) + elt.appendChild(dom.createTextNode(type)) + elt.appendChild(dom.createTextNode(size)) + elt.appendChild(dom.createTextNode(size)) + return elt class Files(XmlFile): @@ -19,8 +28,12 @@ class Files(XmlFile): self.readxml(filename) fileElts = getAllNodes(node, "File") - self.installDeps = [FileInfo(x) for x in fileElts] + self.list = [FileInfo(x) for x in fileElts] def write(self, filename): - pass + #FIXME: need a function to clear DOM first! + for x in list: + pass + #elf.putNode("File/ + diff --git a/pisi/install.py b/pisi/install.py index cb0168b8..f257674f 100644 --- a/pisi/install.py +++ b/pisi/install.py @@ -15,6 +15,9 @@ class PisiInstallError(Exception): pass class PisiInstall: +# tek bir fonksiyon olan bir seyi class yapmak dogru mu? +# ne state sakliyor PisiInstall? + def __init__(self, package_fn): self.install(package_fn) diff --git a/pisi/xmlfile.py b/pisi/xmlfile.py index 29b6d1da..ad7d9d86 100644 --- a/pisi/xmlfile.py +++ b/pisi/xmlfile.py @@ -84,6 +84,35 @@ def getAllNodes(node, tagPath): return nodeList +def appendTagPath(node, tagpath, child): + """append child at the end of a tag chain""" + for tag in tagpath[0:len(tagpath)-1]: + node = node.appendChild(createElement()) + node.appendChild(child) + +def putNode(node, tagpath, newnode): + tags = tagpath.split('/') + + # iterative code to search for the path + + # get DOM for top node + nodeList = node.getElementsByTagName(tags[0]) + if len(nodeList) == 0: + appendTagPath(node, tagpath, newnode) + + node = nodeList[0] # discard other matches + tags.pop(0) + while len(tags)>0: + tag = tags.pop(0) + nodeList = node.getElementsByTagName(tag) + if len(nodeList) == 0: + tags = tag.insert(0) + appendTagPath(node, tags, newnode) + else: + node = nodeList[0] + + return node + # xmlfile class that further abstracts a dom object class XmlFile(object):