[med-svn] r1262 - trunk/community/infrastructure/test
tille at alioth.debian.org
tille at alioth.debian.org
Sat Feb 2 15:14:49 UTC 2008
Author: tille
Date: 2008-02-02 15:14:48 +0000 (Sat, 02 Feb 2008)
New Revision: 1262
Added:
trunk/community/infrastructure/test/cddtasktools.py
Log:
Defined some classes that help reading our tasks files and Packages / Sources files (not finished yet!)
Added: trunk/community/infrastructure/test/cddtasktools.py
===================================================================
--- trunk/community/infrastructure/test/cddtasktools.py (rev 0)
+++ trunk/community/infrastructure/test/cddtasktools.py 2008-02-02 15:14:48 UTC (rev 1262)
@@ -0,0 +1,127 @@
+#!/usr/bin/python
+
+# Meta packages are listing a set of Dependencies
+# These might be fullfilled by the Debian package
+# set or not
+#
+# This interface provides a class DependantPackage
+# which contains all available information about
+# this Dependency , like whether it is an official
+# package or not, in which distribution it is contained
+# or if it is not contained it obtains information
+# from tasks file about home page, license, WNPP etc.
+
+# This is just a test how we should read tasks files
+# using python-debian to make sure everything is
+# processed nicely
+#
+# You should give the path to a tasks file at command
+# line for this simple test
+
+import sys
+import os
+import urllib
+import StringIO
+import gzip
+
+from debian_bundle import deb822
+
+BASEURL = 'http://ftp.debian.de/debian/dists/'
+REPOS = { 'debian-med' : "svn://svn.debian.org/svn/cdd/projects/med/trunk/debian-med/tasks/",
+ 'debian-edu' : "svn://svn.debian.org/svn/debian-edu/trunk/src/debian-edu/tasks/",
+ 'debian-science' : "svn://svn.debian.org/svn/cdd/projects/science/trunk/debian-science/tasks/",
+ }
+HTMLBASE = "/var/lib/gforge/chroot/home/groups"
+
+class Task:
+ # This class just stores name and description of a task package
+
+ def __init__(self, cddname=None, taskname=None, shortDesc=None, longDesc=None):
+ self.cddname = cddname
+ self.taskname = taskname
+ self.shortDesc = shortDesc
+ self.longDesc = longDesc
+
+class DependantPackage:
+ # Hold information about a program that is in dependency list
+
+ def __init__(self, cddname=None, taskname=None):
+ self.cddname = cddname
+ self.taskname = taskname
+ self.dependencytype = None # Values: 'Depends', 'Recommends', 'Suggests'
+ self.dists = [] # Values: 'stable', 'testing', 'unstable', etc.
+ self.component = None # Values: 'main', 'contrib', 'non-free', 'experimental'
+
+ self.why = None # basically used as comment
+
+ # The following keys will be mostly used for programs that
+ # are not yet existing in Debian and will go to our todo list
+ self.homepage = None # Homepage of program
+ self.responsible = None # E-Mail address of issuer of ITP or some person
+ # who volunteered to care for this program
+ self.license = None # License of program
+ self.wnpp = None # WNPP bug number
+ self.pkgShortDesc = None # Prospective packages should have a description ...
+ self.pkgLongDesc = None # ... which could be copied to (or from if exists)
+ # WNPP bug and finally can be used for packaging
+ self.pkgURL = None # URL of inofficial package
+
+class CddDependencies:
+ # Provide a list of depencencies defined in Metapackages
+
+ def __init__(self, cddname):
+
+ if cddname not in REPOS.keys():
+ print >>sys.stderr, "Unknown CDD."
+ return None
+
+ self.cddname = cddname
+ tasks = "%s/%s/data/tasks" % (HTMLBASE, cddname)
+ # Checkout/Update tasks from SVN
+ if os.path.isdir(tasks+'/.svn'):
+ os.system("svn up %s %s >> /dev/null" % (REPOS[self.cddname], tasks))
+ else:
+ os.system("mkdir -p %s" % (tasks))
+ os.system("svn co %s %s >> /dev/null" % (REPOS[self.cddname], tasks))
+
+
+
+class Available:
+ # Information about available packages
+
+ def __init__(self, dist=None, components=(), source=None, arch=None):
+ self.source = 'Packages.gz'
+ if source != None:
+ self.source = 'Sources.gz'
+ self.binary = 'source'
+ if source == None:
+ if arch == None:
+ # use arch=i386 as default because it contains most packages
+ self.binary = 'binary-i386'
+ else:
+ self.binary = 'binary-' + arch
+ self.dist = 'unstable'
+ if dist != None:
+ self.dist = dist
+ self.components = ('main', 'contrib', 'non-free')
+ if components != ():
+ self.components = components
+ self.pkgnames = {}
+ for component in self.components:
+ self.pkgnames[component] = []
+
+ def GetPackageNames(self):
+ # Fetch Packages / Sources file and get list of package names out of it
+
+ for component in self.components:
+ f = urllib.urlopen(BASEURL+'/'+self.dist+'/'+component+'/'+self.binary+'/'+self.source)
+ compresseddata = f.read()
+ compressedstream = StringIO.StringIO(compresseddata)
+ g = gzip.GzipFile(fileobj=compressedstream)
+ for stanza in deb822.Sources.iter_paragraphs(g, shared_storage=False):
+ pieces = stanza['version'].split('-')
+ description = stanza['description'].split('\n')
+ if len(pieces) < 2:
+ self.pkgnames[component].append(stanza['package'])
+ f.close()
+
More information about the debian-med-commit
mailing list