[Blends-commit] r3435 - /blends/trunk/team_analysis_tools/count-dependencies.py

tille at users.alioth.debian.org tille at users.alioth.debian.org
Sat Jun 23 11:40:50 UTC 2012


Author: tille
Date: Sat Jun 23 11:40:50 2012
New Revision: 3435

URL: http://svn.debian.org/wsvn/blends/?sc=1&rev=3435
Log:
Count how many Dependencies are in the metapackages of Debian Med

Added:
    blends/trunk/team_analysis_tools/count-dependencies.py   (with props)

Added: blends/trunk/team_analysis_tools/count-dependencies.py
URL: http://svn.debian.org/wsvn/blends/blends/trunk/team_analysis_tools/count-dependencies.py?rev=3435&op=file
==============================================================================
--- blends/trunk/team_analysis_tools/count-dependencies.py (added)
+++ blends/trunk/team_analysis_tools/count-dependencies.py Sat Jun 23 11:40:50 2012
@@ -1,0 +1,90 @@
+#!/usr/bin/python
+
+"""
+This script imports data about not yet uploaded packages prepared by Blends teams.
+"""
+
+from sys import stderr, exit
+from os import listdir
+from os.path import exists
+from fnmatch import fnmatch
+import re
+from subprocess import Popen, PIPE
+from debian import deb822
+from mx.DateTime import *
+
+debug=0
+
+class taskscontent:
+    def __init__(self, version=None, date=None):
+	self.version = version
+	self.date    = date
+	self.mxdate  = DateFrom(date)
+	self.year    = self.mxdate.year
+	self.month   = self.mxdate.month
+	self.day     = self.mxdate.day
+	self.recommends = {}
+
+    def add_recommends(self, package, recommends):
+        p = package.encode('utf-8')
+	r = recommends.encode('utf-8').split(',')
+	self.recommends[p] = r
+    
+    def __str__(self):
+	s="Version: %s; Date: %s-%02i-%02i:" % (self.version, self.year, int(self.month), int(self.day))
+	for r in self.recommends.keys():
+	    s += '\n  ' + r + ': ' + str(len(self.recommends[r]))
+	return s
+
+def main():
+    root = '../../../projects/med/tags' # FIXME: Blend name should be parameter - currently only used for Debian Med
+    u_dirs = listdir(root)
+
+    versions = {}
+    for u in u_dirs:
+	if u == '.svn':
+	    continue
+        debiandir= root + '/' + u + '/debian/'
+        changelog = debiandir + 'changelog'
+
+        # Read output of dpkg-parsechangelog
+        p = Popen("LC_ALL=C dpkg-parsechangelog -l"+changelog, shell=True, bufsize=4096,
+    	    stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
+        errstring = p.stderr.read()
+        if errstring != '':
+            print >>stderr, "Error parsing changelog of version %s\n %s:" % (u, errstring)
+        for stanza in deb822.Sources.iter_paragraphs(p.stdout):
+    	    if u != stanza['version']:
+    		print >>stderr, "Dir %s does not fit changelog version %s" % (u, stanza['version'])
+    	    else:
+    		task = taskscontent(u, stanza['date'])
+
+    	# Try to read debian/control
+    	ctrlfile = debiandir + 'control'
+    	try:
+    	  ctrl = open(ctrlfile,'r')
+    	except:
+    	  print >>stderr, "Unable to open control file for version %s (%s)" % (u, ctrlfile)
+    	  continue
+    	if ctrl:
+	  ictrl = deb822.Deb822.iter_paragraphs(ctrl)
+	  src = ictrl.next()
+	  pkg = ictrl.next()
+	  while pkg:
+            if pkg.has_key('package'):
+                package = pkg['package']
+    	        if pkg.has_key('recommends'):
+    	            recommends = pkg['recommends']
+    	            task.add_recommends(package,recommends)
+    	    try:
+    		pkg = ictrl.next()
+    	    except:
+    		pkg = None
+
+        print task
+
+
+if __name__ == '__main__':
+  main()
+
+# vim:set et tabstop=2:

Propchange: blends/trunk/team_analysis_tools/count-dependencies.py
------------------------------------------------------------------------------
    svn:executable = *




More information about the Blends-commit mailing list