[med-svn] r1274 - trunk/community/infrastructure/test

tille at alioth.debian.org tille at alioth.debian.org
Sun Feb 3 09:54:11 UTC 2008


Author: tille
Date: 2008-02-03 09:54:11 +0000 (Sun, 03 Feb 2008)
New Revision: 1274

Modified:
   trunk/community/infrastructure/test/cddtasktools.py
   trunk/community/infrastructure/test/update-tasks_using_python-debian
Log:
Store description of Debian package together with dependency


Modified: trunk/community/infrastructure/test/cddtasktools.py
===================================================================
--- trunk/community/infrastructure/test/cddtasktools.py	2008-02-03 07:34:12 UTC (rev 1273)
+++ trunk/community/infrastructure/test/cddtasktools.py	2008-02-03 09:54:11 UTC (rev 1274)
@@ -44,6 +44,17 @@
         os.system("svn co %s %s >> /dev/null" % (REPOS[cddname], tasksdir))
     return tasksdir
 
+def SplitDescription(description):
+    # Split first line of Description value as short description
+    
+    lines = description.splitlines()
+    ShortDesc = lines[0]
+    LongDesc  = ''
+    for line in lines[1:]:
+        LongDesc += line.strip() + '\n'
+    return (ShortDesc, LongDesc)
+
+
 class Task:
     # This class just stores name and description of a task package
 
@@ -62,7 +73,7 @@
         self.pkg            = None # Name of dependant package
         self.dependencytype = None # Values: 'Depends', 'Recommends', 'Suggests'
         self.dists          = []   # Values: 'stable', 'testing', 'unstable', etc.
-        self.component      = None # Values: 'main', 'contrib', 'non-free', 'experimental'
+        self.component      = {} # Values: 'main', 'contrib', 'non-free', 'experimental'
 
         self.why            = None # basically used as comment
 
@@ -161,11 +172,7 @@
                     self.taskPrintedName = stanza['task']
                     continue
                 if key == 'Description':
-                    lines = stanza['description'].splitlines()
-                    self.taskShortDesc = lines[0]
-                    self.taskLongDesc  = ''
-                    for line in lines[1:]:
-                        self.taskLongDesc += line.strip() + '\n'
+                    (self.taskShortDesc, self.taskLongDesc) = SplitDescription(stanza['description'])
                     continue
                 if key == 'Why':
                     why = stanza['why']
@@ -201,8 +208,9 @@
                         dep.dists.append(self.available.dist)
                         # Find the component the Dependency might be in
                         for component in self.available.components:
-                            if dep.pkg in self.available.pkgnames[component]:
-                                dep.component = component
+                            if dep.pkg in self.available.packages[component].keys():
+                                dep.component    = component
+                                (dep.pkgShortDesc, dep.pkgLongDesc) = self.available.packages[component][dep.pkg]
                                 break # The same package should be only in one component
                                       # At least I currently see no reason for having a
                                       # package with the same name in main and contrib
@@ -239,11 +247,7 @@
                         print >>stderr, "Dep not initiatet before Pkg-Description %s -> something is wrong." \
                               % stanza['pkg-description'].splitlines()[0]
                     else:
-                        lines = stanza['pkg-description'].splitlines()
-                        dep.pkgShortDesc = lines[0]
-                        dep.pkgLongDesc  = ''
-                        for line in lines[1:]:
-                            dep.pkgLongDesc += line.strip() + '\n'
+                        (dep.pkgShortDesc, dep.pkgLongDesc) = SplitDescription(stanza['pkg-description'])
                 else:
                     print "Unknown key '%s': %s" % (key, stanza[key])
             if dep != None:
@@ -253,7 +257,7 @@
 
     def _FindDependencyType(self, dep):
         # Return the name of the Dependencytype to append the Dependency to the right list
-        if dep.component != None:
+        if dep.component != {}:
             return 'official'
         if dep.pkgURL != None:
             return 'unofficial'
@@ -280,16 +284,19 @@
         self.components = ('main', 'contrib', 'non-free')
         if components != ():
             self.components = components
-        self.pkgnames = {}
+        # The dictionary packages contains the component as key
+        # The values are dictionaries holding package names as key
+        # and a two element list (pkgShortDesc,pkgLongDesc) as values
+        self.packages = {}
         for component in self.components:
-            self.pkgnames[component] = []
+            self.packages[component] = {}
 
     def GetPackageNames(self):
         # Fetch Packages / Sources file and get list of package names out of it
 
         # Check whether package names are just known
-        for component in self.pkgnames:
-            if self.pkgnames[component] != []:
+        for component in self.packages:
+            if self.packages[component] != {}:
                 # Just got the Package names because at least one component
                 # has non zero elements
                 return
@@ -300,7 +307,7 @@
             compressedstream = StringIO.StringIO(compresseddata)
             g = gzip.GzipFile(fileobj=compressedstream)
             for stanza in deb822.Sources.iter_paragraphs(g, shared_storage=False):
-                self.pkgnames[component].append(stanza['package'])
+                self.packages[component][stanza['package']] = SplitDescription(stanza['description'])
             f.close()
 
 available = Available()

Modified: trunk/community/infrastructure/test/update-tasks_using_python-debian
===================================================================
--- trunk/community/infrastructure/test/update-tasks_using_python-debian	2008-02-03 07:34:12 UTC (rev 1273)
+++ trunk/community/infrastructure/test/update-tasks_using_python-debian	2008-02-03 09:54:11 UTC (rev 1274)
@@ -20,6 +20,9 @@
 from cddtasktools import Available, CddDependencies, Task, TaskDependencies
 
 
+def sorter(x, y):
+	return cmp(x.pkg,y.pkg)
+
 tdeps=TaskDependencies('debian-med', 'bio')
 tdeps.GetTaskDependencies()
 
@@ -37,6 +40,15 @@
 
 sys.exit(0)
 
+print "---------- prospective - sorted  ----------"
+for tdep in tdeps.dependencies['prospective'].sort(sorter):
+    print tdep.pkg, ':', tdep.pkgShortDesc
+
+#for k in ksort(d):
+#print k, v
+
+sys.exit(0)
+
 deps=CddDependencies('debian-science')
 deps.GetTasks()
 
@@ -47,36 +59,20 @@
 available = Available()
 available.GetPackageNames()
 
-for pkg in available.pkgnames['main']:
-    print pkg
+component = 'main'
+print "---------- %s ----------" % component
+for pkg in available.packages[component].keys():
+    print pkg, ':', available.packages[component][pkg][0]
 
-sys.exit(0)
+component = 'contrib'
+print "---------- %s ----------" % component
+for pkg in available.packages[component].keys():
+    print pkg, ':', available.packages[component][pkg][0]
 
-# Some keys might be ignored because they work as
-# comments in the tasks file for the moment
-ignore_keys = [ "Why", "Responsible" ]
+component = 'non-free'
+print "---------- %s ----------" % component
+for pkg in available.packages[component].keys():
+    print pkg, ':', available.packages[component][pkg][0]
 
-# These keys might contain more than one item that
-# has to be separated to detect the dependency
-dependency_keys = [ "Depends", "Recommends", "Suggests" ] 
+sys.exit(0)
 
-
-for fname in sys.argv[1:]:
-    f = file(fname)
-    for stanza in deb822.Sources.iter_paragraphs(f):
-        #        pieces = stanza['version'].split('-')
-        #        if len(pieces) < 2:
-        for key in stanza:
-            if key in ignore_keys:
-                continue
-            if key in dependency_keys:
-                # turn alternatives ('|') into real depends for this purpose
-                # because we are finally interested in all alternatives
-                dependencies = stanza[key].replace('|',',').split(',')
-                for dep in dependencies:
-                    print key, ':', dep.strip()
-            else:
-                print key, ':', stanza[key]
-            
-    f.close()
-




More information about the debian-med-commit mailing list