* 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
|
||||
\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
|
||||
|
||||
+15
-2
@@ -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/
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user