diff --git a/pisi/specfile.py b/pisi/specfile.py
index 74e1b1a5..df183c71 100644
--- a/pisi/specfile.py
+++ b/pisi/specfile.py
@@ -13,7 +13,7 @@ class PackagerInfo:
self.email = getNodeText(getNode(node, "Email"))
def elt(self, xml):
- node = xml.newNode("Update")
+ node = xml.newNode("Packager")
xml.addTextNodeUnder(node, "Name", self.name)
xml.addTextNodeUnder(node, "Email", self.email)
return node
@@ -79,6 +79,7 @@ class SourceInfo:
self.name = getNodeText(node, "Name")
self.homepage = getNodeText(node, "HomePage")
self.packager = PackagerInfo(getNode(node, "Packager"))
+ self.description = getNodeText(node, "Description")
self.license = getNodeText(node, "License")
self.isa = getNodeText(node, "IsA")
self.partof = getNodeText(node, "PartOf")
@@ -99,7 +100,8 @@ class SourceInfo:
xml.addTextNodeUnder(node, "Name", self.name)
if self.homepage:
xml.addTextNodeUnder(node, "Homepage", self.homepage)
- xml.addNodeUnder(node, "", self.packager.elt(xml))
+ node.appendChild(self.packager.elt(xml))
+ xml.addTextNodeUnder(node, "Description", self.description)
xml.addTextNodeUnder(node, "License", self.license)
xml.addTextNodeUnder(node, "IsA", self.isa)
xml.addTextNodeUnder(node, "PartOf", self.partof)
@@ -181,7 +183,7 @@ class SpecFile(XmlFile):
def write(self, filename):
"""Write PSPEC file"""
self.newDOM()
- self.addNode("", self.source.elt(self))
- for pkg in map(lambda x : x.elt(self), self.packages):
- self.addNode("", pkg)
+ self.addChild(self.source.elt(self))
+ for pkg in self.packages:
+ self.addChild(pkg.elt(self))
self.writexml(filename)
diff --git a/pisi/xmlext.py b/pisi/xmlext.py
index 3badf0f0..b11a5876 100644
--- a/pisi/xmlext.py
+++ b/pisi/xmlext.py
@@ -99,21 +99,18 @@ def createTagPath(dom, node, tags):
def addTagPath(dom, node, tags, newnode=None):
"""add newnode at the end of a tag chain, smart one"""
+ node = createTagPath(dom, node, tags)
if newnode: # node to add specified
- last = len(tags)-1
- if last >= 0:
- node = createTagPath(dom, node, tags[0:last])
- node.appendChild(newnode)
- else:
- raise XmlError("addNodePath: not enough tags")
- else:
- return createTagPath(dom, node, tags)
+ node.appendChild(newnode)
+ return node
def addNode(dom, node, tagpath, newnode = None):
"""add a new node at the end of the tree"""
assert type(tagpath)==str
- tags = tagpath.split('/') # tag chain
+ tags = []
+ if tagpath != "":
+ tags = tagpath.split('/') # tag chain
assert len(tags)>0 # we want a chain
# iterative code to search for the path
diff --git a/pisi/xmlfile.py b/pisi/xmlfile.py
index e42125c8..5cdb01ee 100644
--- a/pisi/xmlfile.py
+++ b/pisi/xmlfile.py
@@ -92,13 +92,18 @@ class XmlFile(object):
def addNode(self, tagPath, newnode = None):
self.verifyRootTag()
- return addNode(self.dom, self.dom.documentElement, tagPath, newnode)
+ return addNode(self.dom, self.dom.documentElement, tagPath,
+ newnode)
def addNodeUnder(self, node, tagPath, newnode = None):
"this adds the new stuff under node"
self.verifyRootTag()
return addNode(self.dom, node, tagPath, newnode)
+ def addChild(self, newnode):
+ """add a new child node right under root element document"""
+ self.dom.documentElement.appendChild(newnode)
+
def addText(self, node, text):
"add text to node"
node.appendChild(self.newTextNode(text))
diff --git a/samples/popt/popt.pspec b/samples/popt/popt.pspec
index 7a8a5477..7fa93e6c 100644
--- a/samples/popt/popt.pspec
+++ b/samples/popt/popt.pspec
@@ -15,6 +15,16 @@
As-Is
library:util
rpm:archive
+ Command line option parsing library.
+ While it is similiar to getopt(3), it contains a number of enhancements, including:
+
+ 1) popt is fully reentrant
+ 2) popt can parse arbitrary argv[] style arrays while
+ getopt(2) makes this quite difficult
+ 3) popt allows users to alias command line arguments
+ 4) popt provides convience functions for parsing strings
+ into argv[] style arrays
+
ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.1.x/popt-1.7.tar.gz
@@ -44,23 +54,13 @@
- popt
+ popt-libs
Command line option parsing library
Komut satırı seçenekleri işleme kütüphanesi
- Command line option parsing library.
- While it is similiar to getopt(3), it contains a number of enhancements, including:
-
- 1) popt is fully reentrant
- 2) popt can parse arbitrary argv[] style arrays while
- getopt(2) makes this quite difficult
- 3) popt allows users to alias command line arguments
- 4) popt provides convience functions for parsing strings
- into argv[] style arrays
-
- devel:library
gettext
+ library files for popt
/usr/lib
/usr/share/doc
diff --git a/tests/specfiletests.py b/tests/specfiletests.py
index 4470f5ac..22f5bb20 100644
--- a/tests/specfiletests.py
+++ b/tests/specfiletests.py
@@ -4,6 +4,7 @@ import os
from pisi import specfile
from pisi.config import config
+import pisi.util as util
class SpecFileTestCase(unittest.TestCase):
def setUp(self):
@@ -30,6 +31,7 @@ class SpecFileTestCase(unittest.TestCase):
self.assertEqual(len(self.spec.packages), 1)
def testCopy(self):
+ util.check_dir(config.tmp_dir())
self.spec.read("samples/popt/popt.pspec")
self.spec.write(os.path.join(config.tmp_dir(), 'popt-copy.pspec'))