* fix: XmlFile.getAllNodes returns [] when it finds nothing
* specfile: parse packages except file specs
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@
|
||||
<Dependency>gettext</Dependency>
|
||||
</RuntimeDependencies>
|
||||
<Files>
|
||||
<Path fileType="sharedLib">/usr/lib/</Path>
|
||||
<Path fileType="sharedLib">/usr/lib</Path>
|
||||
<Path fileType="doc">/usr/share/doc</Path>
|
||||
<Path fileType="doc">/usr/share/man</Path>
|
||||
<Path fileType="localedata">/usr/share/locale</Path>
|
||||
|
||||
+12
-3
@@ -20,8 +20,15 @@ class DepInfo:
|
||||
|
||||
class PackageInfo:
|
||||
def __init__(self, node):
|
||||
comps = getChildElts(node)
|
||||
self.name = comps[0]
|
||||
self.name = getNodeText(getNode(node, "Name"))
|
||||
self.summary = getNodeText(getNode(node, "Summary"))
|
||||
self.description = getNodeText(getNode(node, "Description"))
|
||||
self.category = getNodeText(getNode(node, "Category"))
|
||||
iDepElts = getAllNodes(node, "InstallDependencies")
|
||||
self.installDeps = [DepInfo(d) for d in iDepElts]
|
||||
rtDepElts = getAllNodes(node, "RuntimeDependencies")
|
||||
self.runtimeDeps = [DepInfo(d) for d in rtDepElts]
|
||||
|
||||
|
||||
class SpecFile(XmlFile):
|
||||
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
|
||||
@@ -53,7 +60,9 @@ class SpecFile(XmlFile):
|
||||
packageElts = self.getAllNodes("Package")
|
||||
packages = [PackageInfo(p) for p in packageElts]
|
||||
print packages
|
||||
|
||||
for x in packages:
|
||||
print 'package', x.name
|
||||
|
||||
def verify(self):
|
||||
"""Verify PSPEC structures, are they what we want of them?"""
|
||||
return True
|
||||
|
||||
+3
-4
@@ -54,13 +54,12 @@ def getNode(node, tagpath):
|
||||
def getAllNodes(node, tags):
|
||||
"""retrieve all nodes that match a given tag path."""
|
||||
|
||||
print "tags = ", tags
|
||||
if len(tags)==0:
|
||||
return None
|
||||
return []
|
||||
|
||||
nodeList = node.getElementsByTagName(tags[0])
|
||||
if len(nodeList)==0:
|
||||
return None
|
||||
return []
|
||||
|
||||
for tag in tags[1:]:
|
||||
results = map(lambda x: x.getElementsByTagName(tag),nodeList)
|
||||
@@ -70,7 +69,7 @@ def getAllNodes(node, tags):
|
||||
pass # emacs indentation error, keep it here
|
||||
|
||||
if len(nodeList)==0:
|
||||
return None
|
||||
return []
|
||||
|
||||
return nodeList
|
||||
|
||||
|
||||
Reference in New Issue
Block a user