changeset 405:eaf04fc0f615 treepkg-status

moved arch info to each package info
author Bjoern Ricks <bricks@intevation.de>
date Tue, 13 Jul 2010 14:26:11 +0000
parents a798edae0844
children 52e3c3976e53
files treepkg/info/status.py treepkg/info/status.xsd
diffstat 2 files changed, 29 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/treepkg/info/status.py	Tue Jul 13 12:24:14 2010 +0000
+++ b/treepkg/info/status.py	Tue Jul 13 14:26:11 2010 +0000
@@ -43,6 +43,10 @@
     def toxml(self):
         return self.tpkgroot.toxml()
 
+    @staticmethod
+    def fromxml(xml):
+        pass
+
     def add_revisions(self, track, trackinfo):
         revisions = track.get_revisions()
         revisions = sorted(revisions, key=lambda r: r.status.start,
@@ -50,7 +54,6 @@
         if self.numnewestrev > 0:
             revisions = revisions[:self.numnewestrev]
 
-        os =  track.os
         arch = None
 
         for rev in revisions:
@@ -60,30 +63,27 @@
             
             sources = rev.list_source_files()
             binaries = rev.list_binary_files()
-            for binary in binaries: # get arch
-                binpackage =  BinaryPackage(binary)
-                arch = binpackage.get_architecture()
-                if not arch is None:
-                    break;
-            platforminfo = TreepkgPlatformInfo(os, arch)
+
             revinfo = TreepkgTrackRevisionInfo(revision, rules_revision,
-                                               status, platforminfo)
+                                               status)
             logs = rev.get_log_files()
             for (title, filename) in logs:
                 loginfo = TreepkgLogInfo(title, filename)
                 revinfo.add_log(loginfo)
             for source in sources:
-                self.add_package(source, "source", revinfo)
+                self.add_package(revinfo, source, "source")
             for binary in binaries:
-                self.add_package(binary, "binary", revinfo)
- 
+                binpackage =  BinaryPackage(binary)
+                arch = binpackage.get_architecture()
+                self.add_package(revinfo, binary, "binary", arch)
+
             trackinfo.add_revision(revinfo)
 
-    def add_package(self, file, type, revision):
+    def add_package(self, revision, file, type, arch=None):
         name = os.path.basename(file)
         checksum = md5sum(file)
         checksuminfo = TreepkgChecksumInfo(checksum, "md5")
-        pkginfo = TreepkgPackageInfo(name, file, type)
+        pkginfo = TreepkgPackageInfo(name, file, type, arch)
         pkginfo.add_checksum(checksuminfo)
         revision.add_package(pkginfo)
 
@@ -133,8 +133,9 @@
 
 class TreepkgTrackInfo:
     
-    def __init__(self, name):
+    def __init__(self, name, os=None):
         self.name = name
+        self.os = os
         self.revisions = []
 
     def add_revision(self, revision):
@@ -148,15 +149,19 @@
         root.appendChild(nameele)
         for rev in self.revisions:
             root.appendChild(rev.toxml())
+        if not self.os is None:
+            osele = createTpkgElement(doc, "os")
+            text = doc.createTextNode(self.os)
+            osele.appendChild(text)
+            root.appendChild(osele)
         return root
 
 class TreepkgTrackRevisionInfo:
 
-    def __init__(self, number, rules, status, platform):
+    def __init__(self, number, rules, status):
         self.number = number
         self.rules = rules
         self.status = status
-        self.platform = platform
         self.packages = []
         self.logs = []
 
@@ -185,8 +190,6 @@
         messageele.appendChild(text)
         statusele.appendChild(messageele)
         root.appendChild(statusele)
-        # add <platform>
-        root.appendChild(self.platform.toxml())
         # add <packages>
         packagesele = createTpkgElement(doc, "packages")
         for package in self.packages:
@@ -199,28 +202,6 @@
         root.appendChild(logsele)
         return root
 
-class TreepkgPlatformInfo:
-
-    def __init__(self, os, arch):
-        self.os = os
-        self.arch = arch
-        if self.arch is None:
-            self.arch = "unkown"
-
-    def toxml(self):
-        (doc, root) = createTpkgRoot("platform")
-        # add <os>
-        osele = createTpkgElement(doc, "os")
-        text = doc.createTextNode(self.os)
-        osele.appendChild(text)
-        root.appendChild(osele)
-        # add <arch>
-        archele = createTpkgElement(doc, "arch")
-        text = doc.createTextNode(self.arch)
-        archele.appendChild(text)
-        root.appendChild(archele)
-        return root
-
 class TreepkgLogInfo:
 
     def __init__(self, name, path):
@@ -243,10 +224,11 @@
 
 class TreepkgPackageInfo:
         
-    def __init__(self, name, path, type):
+    def __init__(self, name, path, type, arch):
         self.name = name
         self.path = path
         self.type = type
+        self.arch = arch
         self.checksums = [] 
 
     def toxml(self):
@@ -265,10 +247,9 @@
         for checksum in self.checksums:
             root.appendChild(checksum.toxml())
         # add <type>
-        typeele = createTpkgElement(doc, "type")
-        text = doc.createTextNode(self.type)
-        typeele.appendChild(text)
-        root.appendChild(typeele)
+        root.setAttributeNS(TREEPKG_NAMESPACE_URI, "type", self.type)
+        if not self.arch is None:
+            root.setAttributeNS(TREEPKG_NAMESPACE_URI, "arch", self.arch)
         return root
 
     def add_checksum(self, checksum):
--- a/treepkg/info/status.xsd	Tue Jul 13 12:24:14 2010 +0000
+++ b/treepkg/info/status.xsd	Tue Jul 13 14:26:11 2010 +0000
@@ -35,6 +35,7 @@
             <xsd:element name="name" type="xsd:string" minOccurs="1"/>
             <xsd:element name="revision" type="tpkg:revision"
             maxOccurs="unbounded"/>
+            <xsd:element name="os" type="xsd:string"/>
         </xsd:sequence>
     </xsd:complexType>
 
@@ -43,7 +44,6 @@
             <xsd:element name="number" type="xsd:string" minOccurs="1"/>
             <xsd:element name="rules" type="xsd:string" minOccurs="1"/>
             <xsd:element name="status" type="tpkg:revisionstatus" minOccurs="1"/>
-            <xsd:element name="platform" type="tpkg:platform" minOccurs="1"/>
             <xsd:element name="packages" type="tpkg:packages"/>
             <xsd:element name="logs" type="tpkg:logs"/>
         </xsd:sequence>
@@ -55,13 +55,6 @@
         </xsd:sequence>
     </xsd:complexType>
 
-    <xsd:complexType name="platform">
-        <xsd:sequence>
-            <xsd:element name="os" type="xsd:string"/>
-            <xsd:element name="arch" type="xsd:string"/>
-       </xsd:sequence>
-    </xsd:complexType>
-
     <xsd:complexType name="logs">
         <xsd:sequence>
             <xsd:element name="log" type="tpkg:log"/>
@@ -88,8 +81,9 @@
             <xsd:element name="path" type="xsd:string" minOccurs="1">
             <xsd:element name="checksum" type="tpkg:checksum"
                          maxOccurs="unbounded" default="md5"/>
-            <xsd:element name="type" type="tpkg:pkgtype" minOccurs="1"/>
         </xsd:sequence>
+        <xsd:attribute name="type" type="tpkg:pkgtype" minOccurs="1"/>
+        <xsd:attribute name="arch" type="xsd:string"/>
     </xsd:complexType>
 
     <xsd:complexType name="checksum">
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)