* files icin write yapmaya basla
* xmlfile'daki write fonksiyonlarina basla * PisiInstall class'iyle ilgili bir not dus
This commit is contained in:
@@ -831,6 +831,9 @@ files.xml dosyalar
|
|||||||
pisi-files.dtd
|
pisi-files.dtd
|
||||||
\emph default
|
\emph default
|
||||||
dosyasında tanımlanmıştır.
|
dosyasında tanımlanmıştır.
|
||||||
|
\layout Standard
|
||||||
|
|
||||||
|
Bunlarin da acaba attribute seklinde olmasi daha mi dogru olur? -- Eray
|
||||||
\layout Subsection
|
\layout Subsection
|
||||||
|
|
||||||
PSPEC Deposu
|
PSPEC Deposu
|
||||||
|
|||||||
+15
-2
@@ -3,12 +3,21 @@
|
|||||||
|
|
||||||
|
|
||||||
class FileInfo:
|
class FileInfo:
|
||||||
|
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
self.path = getNodeText(getNode(node, "Path"))
|
self.path = getNodeText(getNode(node, "Path"))
|
||||||
self.type = getNodeText(getNode(node, "Type"))
|
self.type = getNodeText(getNode(node, "Type"))
|
||||||
self.size = int(getNodeText(getNode(node, "Size")))
|
self.size = int(getNodeText(getNode(node, "Size")))
|
||||||
self.md5Sum = getNodeText(getNode(node, "MD5Sum"))
|
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):
|
class Files(XmlFile):
|
||||||
|
|
||||||
@@ -19,8 +28,12 @@ class Files(XmlFile):
|
|||||||
self.readxml(filename)
|
self.readxml(filename)
|
||||||
|
|
||||||
fileElts = getAllNodes(node, "File")
|
fileElts = getAllNodes(node, "File")
|
||||||
self.installDeps = [FileInfo(x) for x in fileElts]
|
self.list = [FileInfo(x) for x in fileElts]
|
||||||
|
|
||||||
def write(self, filename):
|
def write(self, filename):
|
||||||
pass
|
#FIXME: need a function to clear DOM first!
|
||||||
|
for x in list:
|
||||||
|
pass
|
||||||
|
#elf.putNode("File/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ class PisiInstallError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class PisiInstall:
|
class PisiInstall:
|
||||||
|
# tek bir fonksiyon olan bir seyi class yapmak dogru mu?
|
||||||
|
# ne state sakliyor PisiInstall?
|
||||||
|
|
||||||
def __init__(self, package_fn):
|
def __init__(self, package_fn):
|
||||||
self.install(package_fn)
|
self.install(package_fn)
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,35 @@ def getAllNodes(node, tagPath):
|
|||||||
return nodeList
|
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
|
# xmlfile class that further abstracts a dom object
|
||||||
|
|
||||||
class XmlFile(object):
|
class XmlFile(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user