* 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>
|
<Dependency>gettext</Dependency>
|
||||||
</RuntimeDependencies>
|
</RuntimeDependencies>
|
||||||
<Files>
|
<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/doc</Path>
|
||||||
<Path fileType="doc">/usr/share/man</Path>
|
<Path fileType="doc">/usr/share/man</Path>
|
||||||
<Path fileType="localedata">/usr/share/locale</Path>
|
<Path fileType="localedata">/usr/share/locale</Path>
|
||||||
|
|||||||
+11
-2
@@ -20,8 +20,15 @@ class DepInfo:
|
|||||||
|
|
||||||
class PackageInfo:
|
class PackageInfo:
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
comps = getChildElts(node)
|
self.name = getNodeText(getNode(node, "Name"))
|
||||||
self.name = comps[0]
|
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):
|
class SpecFile(XmlFile):
|
||||||
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
|
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
|
||||||
@@ -53,6 +60,8 @@ class SpecFile(XmlFile):
|
|||||||
packageElts = self.getAllNodes("Package")
|
packageElts = self.getAllNodes("Package")
|
||||||
packages = [PackageInfo(p) for p in packageElts]
|
packages = [PackageInfo(p) for p in packageElts]
|
||||||
print packages
|
print packages
|
||||||
|
for x in packages:
|
||||||
|
print 'package', x.name
|
||||||
|
|
||||||
def verify(self):
|
def verify(self):
|
||||||
"""Verify PSPEC structures, are they what we want of them?"""
|
"""Verify PSPEC structures, are they what we want of them?"""
|
||||||
|
|||||||
+3
-4
@@ -54,13 +54,12 @@ def getNode(node, tagpath):
|
|||||||
def getAllNodes(node, tags):
|
def getAllNodes(node, tags):
|
||||||
"""retrieve all nodes that match a given tag path."""
|
"""retrieve all nodes that match a given tag path."""
|
||||||
|
|
||||||
print "tags = ", tags
|
|
||||||
if len(tags)==0:
|
if len(tags)==0:
|
||||||
return None
|
return []
|
||||||
|
|
||||||
nodeList = node.getElementsByTagName(tags[0])
|
nodeList = node.getElementsByTagName(tags[0])
|
||||||
if len(nodeList)==0:
|
if len(nodeList)==0:
|
||||||
return None
|
return []
|
||||||
|
|
||||||
for tag in tags[1:]:
|
for tag in tags[1:]:
|
||||||
results = map(lambda x: x.getElementsByTagName(tag),nodeList)
|
results = map(lambda x: x.getElementsByTagName(tag),nodeList)
|
||||||
@@ -70,7 +69,7 @@ def getAllNodes(node, tags):
|
|||||||
pass # emacs indentation error, keep it here
|
pass # emacs indentation error, keep it here
|
||||||
|
|
||||||
if len(nodeList)==0:
|
if len(nodeList)==0:
|
||||||
return None
|
return []
|
||||||
|
|
||||||
return nodeList
|
return nodeList
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user