* spec ornegini biraz daha genislet
* write'lari duzeltirken xmlext'den gereksiz code cikarip biraz basitlestir * ufak tefek duzeltmeler
This commit is contained in:
+7
-5
@@ -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)
|
||||
|
||||
+6
-9
@@ -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
|
||||
|
||||
+6
-1
@@ -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))
|
||||
|
||||
+12
-12
@@ -15,6 +15,16 @@
|
||||
<License>As-Is</License>
|
||||
<IsA>library:util</IsA>
|
||||
<PartOf>rpm:archive</PartOf>
|
||||
<Description>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
|
||||
</Description>
|
||||
<Archive archType="targz" sha1sum="66f3c77b87a160951b180447f4a6dce68ad2f71b">
|
||||
ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.1.x/popt-1.7.tar.gz
|
||||
</Archive>
|
||||
@@ -44,23 +54,13 @@
|
||||
</Source>
|
||||
|
||||
<Package>
|
||||
<Name>popt</Name>
|
||||
<Name>popt-libs</Name>
|
||||
<Summary xml:lang="en">Command line option parsing library</Summary>
|
||||
<Summary xml:lang="tr">Komut satırı seçenekleri işleme kütüphanesi</Summary>
|
||||
<Description>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
|
||||
</Description>
|
||||
<Category>devel:library</Category>
|
||||
<RuntimeDependencies>
|
||||
<Dependency>gettext</Dependency>
|
||||
</RuntimeDependencies>
|
||||
<Description>library files for popt</Description>
|
||||
<Files>
|
||||
<Path fileType="sharedLib">/usr/lib</Path>
|
||||
<Path fileType="doc">/usr/share/doc</Path>
|
||||
|
||||
@@ -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'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user