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

tille at alioth.debian.org tille at alioth.debian.org
Wed Feb 6 19:47:45 UTC 2008


Author: tille
Date: 2008-02-06 19:47:45 +0000 (Wed, 06 Feb 2008)
New Revision: 1334

Added:
   trunk/community/infrastructure/test/update-tasks
Modified:
   trunk/community/infrastructure/test/cddtasktools.py
Log:
Try to reimplement update-tasks with possibly less changes (not working yet)


Modified: trunk/community/infrastructure/test/cddtasktools.py
===================================================================
--- trunk/community/infrastructure/test/cddtasktools.py	2008-02-06 14:20:43 UTC (rev 1333)
+++ trunk/community/infrastructure/test/cddtasktools.py	2008-02-06 19:47:45 UTC (rev 1334)
@@ -138,17 +138,20 @@
             td.GetTaskDependencies()
             self.tasks[task] = td
 
-    def GetNamesOnlyDict(self):
+    def GetNamesOnlyDict(self, dependencytypes=()):
         # David Paleino needs for his web tools a dictionary
         # { taskname : [list of dependencies]}
         # This will be prepared here from the main
         # datastructure
         ret = {}
+        if dependencytypes == ():
+            dependencytypes=('official', 'unofficial', 'prospective')
         for task in self.tasknames:
             tdeps = self.tasks[task]
             list = []
-            for tdep in tdeps.dependencies['official']:
-                list.append(tdep.pkg)
+            for dep in dependencytypes:
+                for tdep in tdeps.dependencies[dep]:
+                    list.append(tdep.pkg)
             ret[task] = list
         return ret
 
@@ -325,11 +328,11 @@
     #
     # Usage example:
     #    available = Available(                     # Initialize instance
-                               dist='testing',      # (default='unstable')
-                               components=('main'), # Regard only main, default: main, contrib, non-free
-                               source=1             # Use source package names, default: use binaries
-                               arch='sparc'         # (default='i386')
-    #                          )
+    #                          dist='testing',      # (default='unstable')
+    #                          components=('main'), # Regard only main, default: main, contrib, non-free
+    #                          source=1             # Use source package names, default: use binaries
+    #                          arch='sparc'         # (default='i386')
+    #                         )
     # 
     #    available.GetPackageNames() # Actually parse the Packages files to obtain needed information
     #                                # This has to be done at least once.  It is verified that the effort

Added: trunk/community/infrastructure/test/update-tasks
===================================================================
--- trunk/community/infrastructure/test/update-tasks	                        (rev 0)
+++ trunk/community/infrastructure/test/update-tasks	2008-02-06 19:47:45 UTC (rev 1334)
@@ -0,0 +1,191 @@
+#!/usr/bin/python -W ignore
+
+#
+# This Python script is:
+#  (C) 2007, David Paleino <d.paleino at gmail.com>
+#
+# It is licensed under the terms of GNU General Public License (GPL)
+# v3, or any later revision.
+#
+
+import apt
+import apt_pkg
+import apt_inst
+import HTMLTemplate
+import re
+import sys
+import time
+from datetime import datetime
+from email.Utils import formatdate
+
+from cddtasktools import CddDependencies, HTMLBASE
+
+CDD='debian-med'
+
+###
+# Template handlers
+###
+
+def renderIndex(node, tasks):
+	node.tasks.repeat(renderTaskList, tasks)
+	t = datetime.now()
+	node.date.content = formatdate(time.mktime(t.timetuple()))
+
+def renderTaskList(node, task):
+	node.task.raw = """<a href="/tasks/%s.php" name="%s" id="%s">%s</a>""" % (task, task, task, task.capitalize())
+
+def renderTasks(node, task, packages, details):
+	global cdeps
+	
+	node.task.content = details['Task']
+	node.shortdesc.content = details['ShortDesc']
+	node.heading.content = details['ShortDesc']
+	node.longdesc.content = details['LongDesc']
+
+	t = datetime.now()
+	node.date.content = formatdate(time.mktime(t.timetuple()))
+
+	official = cdeps.GetNamesOnlyDict(('official',))
+	if task in official:
+		node.official_head.raw = """<h2>
+<a id="official-debs" name="official-debs"></a>
+	Official Debian packages
+</h2>"""
+		node.official.repeat(renderOfficial, official[task], task)
+
+	if task in todo:
+		error = True
+	else:
+		error = False
+
+	unofficial = cdeps.GetNamesOnlyDict(('unofficial',))
+	if task in unofficial:
+		node.unofficial_head.raw = """<h2>
+<a id="inofficial-debs" name="inofficial-debs"></a>
+	Inofficial Debian packages
+</h2>"""
+		node.unofficial.repeat(renderUnofficial, unofficial[task])
+		error = False
+
+	unavailable = cdeps.GetNamesOnlyDict(('prospective',))
+	if task in unavailable:
+		node.unavailable_head.raw = """<h2>
+<a id="debs-not-available" name="debs-not-available"></a>
+	Debian packages not available
+</h2>"""
+		node.unavailable.repeat(renderUnavailable, unavailable[task])
+		error = False
+
+	if error:
+		# The package probably needs a proper prospective entry in the
+		# task files. Write it to stdout.
+		print "Error: problems with %s" % task
+
+def renderOfficial(node, package, task):
+	# Here we parse just official packages
+	node.shortdesc.content = det[package]['ShortDesc']
+	node.project.raw = "<table class=\"project\" summary=\"%s\">" % package
+	node.anchor.atts['name'] = package
+	node.anchor.atts['id'] = package
+	node.name.content = package.capitalize()
+	node.url.atts['href'] = det[package]['Homepage']
+	if det[package]['Homepage'] == "#":
+		node.url.content = "Homepage not available"
+	else:
+		node.url.content = det[package]['Homepage']
+
+	node.longdesc.raw = det[package]['LongDesc']
+	node.version.content = "Version: %s" % det[package]['Version']
+	node.license.content = "License: %s" % det[package]['License']
+	node.pkgurl.atts['href'] = det[package]['Pkg-URL']
+	node.pkgurl.content = "Official Debian package"
+	node.deburl.atts['href'] = det[package]['Deb-URL']
+	#~ node.deburl.content = "X" ### TODO: add a nice icon here to download the .deb package
+	node.deburl.raw = "<img src=\"/img/deb-icon.png\" />"
+
+def renderUnofficial(node, package):
+	# Here we parse just unofficial packages
+	node.shortdesc.content = package['ShortDesc']
+	node.longdesc.raw = package['LongDesc']
+	node.project.raw = "<table class=\"project\" summary=\"%s\">" % package['Package']
+	node.anchor.atts['name'] = package['Package']
+	node.anchor.atts['id'] = package['Package']
+	node.name.content = package['Package'].capitalize()
+	node.url.atts['href'] = package['Homepage']
+	node.url.content = package['Homepage']
+	node.license.content = "License: %s" %package['License']
+	node.pkgurl.atts['href'] = package['Pkg-URL']
+	node.pkgurl.content = "Inofficial Debian package"
+
+	# Let's try to get the version from the package name
+	# (following Debian standards: <name>_<ver>_<arch>.deb)
+	regex = ".*/%s_(?P<version>.*)_.*\.deb$" % package['Package']
+	p = re.compile(regex)
+	m = p.search(package['Pkg-URL'])
+	if m:
+		node.version.content = "Version: %s" % m.group("version")
+	else:
+		node.version.content = "Version: N/A"
+
+
+def renderUnavailable(node, package):
+	# Parsing unavailable packages :(
+	# PACKAGE THEM! :)
+	name = package['Package']
+	if package['ShortDesc']:
+		node.shortdesc.content = package['ShortDesc']
+	else:
+		node.shortdesc.content = "N/A"
+	node.longdesc.raw = package['LongDesc']
+	node.project.raw = "<table class=\"project\" summary=\"%s\">" % name
+	if package['Responsible']:
+		node.responsible.content = package['Responsible']
+	else:
+		node.responsible.raw = "no one"
+	if package['WNPP']:
+		node.wnpp.raw = " &mdash; <a href=\"http://bugs.debian.org/%s\">wnpp</a>" % package['WNPP']
+	node.anchor.atts['name'] = name
+	node.anchor.atts['id'] = name
+	node.name.content = name.capitalize()
+	if package['Homepage']:
+		node.url.atts['href'] = package['Homepage']
+		node.url.content = package['Homepage']
+	else:
+		node.url.atts['href'] = "#"
+		node.url.content = "N/A"
+	if package['License']:
+		node.license.raw = "<?=_('License')?>: %s" % package['License']
+	else:
+		node.license.raw = "<?=_('License')?>: N/A"
+
+cdeps=CddDependencies('debian-med')
+cdeps.GetAllDependencies()
+
+base=HTMLBASE + '/' + CDD
+# Let's render the Tasks Page index, first
+f = open("%s/htdocs/tasks_idx.tmpl" % base)
+tmpl = HTMLTemplate.Template(renderIndex, f.read())
+f.close()
+f = open("%s/static/tasks/index.php" % base, "w")
+
+tasks        = cdeps.tasknames
+packages     = cdeps.GetNamesOnlyDict()
+task_details = cdeps.GetTaskDescDict()
+
+f.write(tmpl.render(tasks))
+f.close()
+
+# Let's render single pages now.
+f = open("%s/htdocs/tasks.tmpl" % base)
+tmpl = HTMLTemplate.Template(renderTasks, f.read())
+f.close()
+
+for task in tasks:
+	f = open("%s/static/tasks/%s.php" % (base, task), "w")
+
+	# This is to avoid useless <br>eaks before closing the cell
+	source = tmpl.render(task, packages[task], task_details[task])
+	f.write(re.sub(r"<br /><br />[ ]*</td>", "</td>", source))
+
+	f.close()
+


Property changes on: trunk/community/infrastructure/test/update-tasks
___________________________________________________________________
Name: svn:executable
   + *




More information about the debian-med-commit mailing list