[Blends-commit] [SCM] website branch, master, updated. 21e2943ac77d0c349a804f44e53fec67179c7e6f

Andreas Tille tille at debian.org
Wed May 18 08:21:33 UTC 2016


The following commit has been merged in the master branch:
commit b2e7b3992e16e33d4b72e70e035102c2749f6bb8
Author: Andreas Tille <tille at debian.org>
Date:   Tue May 17 17:55:13 2016 +0200

    Close to Python3 port - no idea how to replace mxdatetime

diff --git a/misc/team_analysis_tools/count-dependencies.py b/misc/team_analysis_tools/count-dependencies.py
index 84b4432..6b331ea 100755
--- a/misc/team_analysis_tools/count-dependencies.py
+++ b/misc/team_analysis_tools/count-dependencies.py
@@ -4,6 +4,8 @@
 This script extracts numbers of dependencies of different metapackages of a Blend
 """
 
+from __future__ import print_function
+
 from sys import stderr, exit, argv
 from os import listdir
 from os.path import isfile, exists
@@ -36,20 +38,20 @@ SUPPRESSTASKS = { 'med': [ 'cloud' ],
 def TasksGetDrawList(tasks, checklist, avoidlist):
     try:
         task_last = tasks[sorted(tasks.keys())[-1]]
-    except IndexError, err:
-	print >>stderr, err
-	print >>stderr, "tasks.keys() =", tasks.keys()
-	exit()
+    except IndexError as err:
+        print(err, file=stderr)
+        print("tasks.keys() =", list(tasks.keys()), file=stderr)
+        exit()
     # evaluate minimum number of dependencies to draw
     min2draw = 100
     drawlist = []
     for t in checklist:
-        print t, task_last.nrecommended[t]
-	if task_last.nrecommended[t] < min2draw:
-	    min2draw = task_last.nrecommended[t]
-    for r in task_last.recommends.keys():
-	if task_last.nrecommended[r] >= min2draw:
-	    if r not in avoidlist:
+        print(t, task_last.nrecommended[t])
+        if task_last.nrecommended[t] < min2draw:
+            min2draw = task_last.nrecommended[t]
+    for r in list(task_last.recommends.keys()):
+        if task_last.nrecommended[r] >= min2draw:
+            if r not in avoidlist:
                 drawlist.append(r)
 
     drawlist.sort()
@@ -59,50 +61,50 @@ def TasksGetDrawList(tasks, checklist, avoidlist):
 class taskscontent:
     def __init__(self, blend=None, version=None, date=None, htask=None, hrecommended=None):
         self.blend      = blend
-	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.datekey    = "%04i%02i%02i" % (self.year, self.month, self.day)
-	self.recommends	= {}
-	self.nrecommended = {}
-	if htask != None and hrecommended != None:
-	    self.nrecommended[htask] = int(hrecommended)
-	    self.recommends[htask] = []
-	self.ctrlfile	= 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.datekey    = "%04i%02i%02i" % (self.year, self.month, self.day)
+        self.recommends	= {}
+        self.nrecommended = {}
+        if htask != None and hrecommended != None:
+            self.nrecommended[htask] = int(hrecommended)
+            self.recommends[htask] = []
+        self.ctrlfile	= None
 
     def add_recommends(self, package, recommends):
         p = re.sub(self.blend+'-', '', package.encode('utf-8'))
 
-	if not self.recommends.has_key(p):
-	    self.recommends[p] = []
-	for r in recommends.encode('utf-8').split(','):
-	    r = r.strip()
-	    # since we also need to investigate "Depends" for older metapackages we also
-	    # need to exclude the extra control packages
-	    if r.startswith(self.blend+'-common') or r.startswith(self.blend+'-config') or r.startswith(self.blend+'-tasks'):
-		continue
-	    self.recommends[p].append(r)
-	self.nrecommended[p] = len(self.recommends[p])
+        if p not in self.recommends:
+            self.recommends[p] = []
+        for r in recommends.encode('utf-8').split(','):
+            r = r.strip()
+            # since we also need to investigate "Depends" for older metapackages we also
+            # need to exclude the extra control packages
+            if r.startswith(self.blend+'-common') or r.startswith(self.blend+'-config') or r.startswith(self.blend+'-tasks'):
+                 continue
+            self.recommends[p].append(r)
+        self.nrecommended[p] = len(self.recommends[p])
 
     def __str__(self):
-	s="Version: %s; Date: %s-%02i-%02i:" % (self.version, self.year, int(self.month), int(self.day))
-	for r in sorted(self.recommends.keys()):
-	    if not self.nrecommended.has_key(r):
-		self.nrecommended[r] = len(self.recommends[r])
-	    s += '\n  ' + r + ': ' + str(self.nrecommended[r])
-	return s
+        s="Version: %s; Date: %s-%02i-%02i:" % (self.version, self.year, int(self.month), int(self.day))
+        for r in sorted(self.recommends.keys()):
+            if r not in self.nrecommended:
+                self.nrecommended[r] = len(self.recommends[r])
+            s += '\n  ' + r + ': ' + str(self.nrecommended[r])
+        return s
 
 
 def main():
     if len(argv) < 3:
-	print >>stderr, "Usage: %s <path_to_svn_export_of_blends_repository> <blend>" % argv[0]
-	exit()
-    if argv[2] not in DRAWTASKS.keys():
-	print >>stderr, "This script is only prepared for %s" % str(VALIDBLENDS)
-	exit()
+        print("Usage: %s <path_to_svn_export_of_blends_repository> <blend>" % argv[0], file=stderr)
+        exit()
+    if argv[2] not in list(DRAWTASKS.keys()):
+        print("This script is only prepared for %s" % str(VALIDBLENDS), file=stderr)
+        exit()
     BLEND = argv[2]
     root = argv[1]+'/projects/'+BLEND+'/tags' 
     u_dirs = listdir(root)
@@ -112,148 +114,148 @@ def main():
 
     # Read some data about first med-* packages which never made it into any Vcs
     if BLEND == 'med':
-	import json
-	fp=open('med_historical_data.json')
-	mjs=fp.read()
-	medhist = json.loads(mjs)
-	fp.close()
-	for mver in medhist:
-	    if not mver.has_key('task'):
-		continue
-	    if mver['task'] == 'bio-contrib':
-		# we are not interested in non-free dependencies
-		continue
-	    if mver['task'] == 'dent':
-		mver['task'] = 'dental'
-	    if not mver['task'] in tasks_found:
-		tasks_found.append(mver['task'])
-	    task = taskscontent(BLEND, mver['version'], mver['date'], mver['task'], mver['recommends'])
-	    if tasks.has_key(task.datekey):
-		# try to match several single metapackages to what we know today as multibinary
-		mtask = tasks[task.datekey]
-		if mtask.version != task.version:
-		    mtask.version = mtask.version + '+' + task.version
-		if mtask.recommends.has_key(mver['task']):
-		    print >>stderr, "Duplicated task at same date."
-		    continue
-		mtask.recommends[mver['task']] = []
-		mtask.nrecommended[mver['task']] = int(mver['recommends'])
-	    else:
-		tasks[task.datekey] = task
+        import json
+        fp=open('med_historical_data.json')
+        mjs=fp.read()
+        medhist = json.loads(mjs)
+        fp.close()
+        for mver in medhist:
+            if 'task' not in mver:
+                continue
+            if mver['task'] == 'bio-contrib':
+                # we are not interested in non-free dependencies
+                continue
+            if mver['task'] == 'dent':
+                mver['task'] = 'dental'
+            if not mver['task'] in tasks_found:
+                tasks_found.append(mver['task'])
+            task = taskscontent(BLEND, mver['version'], mver['date'], mver['task'], mver['recommends'])
+            if task.datekey in tasks:
+                # try to match several single metapackages to what we know today as multibinary
+                mtask = tasks[task.datekey]
+                if mtask.version != task.version:
+                    mtask.version = mtask.version + '+' + task.version
+                if mver['task'] in mtask.recommends:
+                    print("Duplicated task at same date.", file=stderr)
+                    continue
+                mtask.recommends[mver['task']] = []
+                mtask.nrecommended[mver['task']] = int(mver['recommends'])
+            else:
+                tasks[task.datekey] = task
 
     for u in u_dirs:
-	if u == '.svn':
-	    continue
-	if len(u.split('.')) > 2:
-	    # print >>stderr, "Minor releases usually add no new Dependencies - version %s ignored." % u
-	    continue
+        if u == '.svn':
+            continue
+        if len(u.split('.')) > 2:
+            # print >>stderr, "Minor releases usually add no new Dependencies - version %s ignored." % u
+            continue
         debiandir= root + '/' + u + '/debian/'
         changelog = debiandir + 'changelog'
-	if not exists(changelog):
-	    # print >>stderr, "Version %s seems to be an old package layout tag which is ignored here" % u
-	    continue
+        if not exists(changelog):
+            # print >>stderr, "Version %s seems to be an old package layout tag which is ignored here" % u
+            continue
 
         # 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)
+                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)
+            print("Error parsing changelog of version %s\n %s:" % (u, errstring), file=stderr)
         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(BLEND, u, stanza['date'])
+            if u != stanza['version']:
+                print("Dir %s does not fit changelog version %s" % (u, stanza['version']), file=stderr)
+            else:
+                task = taskscontent(BLEND, u, stanza['date'])
 
-    	# Try to read debian/control
-    	ctrlfile = debiandir + 'control'
-	if isfile(ctrlfile):
-	    task.ctrlfile = ctrlfile
-	    tasks[task.datekey] = task
-    	else:
-    	  print >>stderr, "Unable to open control file for version %s (%s)" % (u, ctrlfile)
-	try:
-	    ctrl = open(task.ctrlfile, 'r')
-	except:
-	    print >>stderr, "Unable to open control file for version %s (%s) ... even if file exists" % (task.version, task.ctrlfile)
-    	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 package != BLEND+'-common' and package != BLEND+'-tasks' and package != BLEND+'-config':
-		    if package == 'med-dent':
-			package = 'med-dental'
-		    if not package.replace(BLEND+'-', '') in tasks_found:
-			tasks_found.append(package.replace(BLEND+'-', ''))
-                    if pkg.has_key('recommends'):
-    	                recommends = pkg['recommends']
-    	                task.add_recommends(package,recommends)
-    	            # in previous package versions we use Depends rather then Recommends
-    	            if pkg.has_key('depends'):
-    	                depends = pkg['depends']
-    	                task.add_recommends(package,depends)
-    	        try:
-    		    pkg = ictrl.next()
-    	        except:
-    		    pkg = None
+        # Try to read debian/control
+        ctrlfile = debiandir + 'control'
+        if isfile(ctrlfile):
+            task.ctrlfile = ctrlfile
+            tasks[task.datekey] = task
+        else:
+            print("Unable to open control file for version %s (%s)" % (u, ctrlfile), file=stderr)
+        try:
+            ctrl = open(task.ctrlfile, 'r')
+        except:
+            print("Unable to open control file for version %s (%s) ... even if file exists" % (task.version, task.ctrlfile), file=stderr)
+        if ctrl:
+            ictrl = deb822.Deb822.iter_paragraphs(ctrl)
+            src = next(ictrl)
+            pkg = next(ictrl)
+            while pkg:
+                if 'package' in pkg:
+                    package = pkg['package']
+                    if package != BLEND+'-common' and package != BLEND+'-tasks' and package != BLEND+'-config':
+                        if package == 'med-dent':
+                            package = 'med-dental'
+                        if not package.replace(BLEND+'-', '') in tasks_found:
+                            tasks_found.append(package.replace(BLEND+'-', ''))
+                        if 'recommends' in pkg:
+                            recommends = pkg['recommends']
+                            task.add_recommends(package,recommends)
+                        # in previous package versions we use Depends rather then Recommends
+                        if 'depends' in pkg:
+                            depends = pkg['depends']
+                            task.add_recommends(package,depends)
+                    try:
+            	        pkg = next(ictrl)
+                    except:
+            	        pkg = None
 
     if not tasks_found:
-        print >>stderr, "No tasks found for Blend %s." % BLEND
+        print("No tasks found for Blend %s." % BLEND, file=stderr)
         exit()
     tasks_found.sort()
 
     drawlist = TasksGetDrawList(tasks, DRAWTASKS[BLEND], SUPPRESSTASKS[BLEND])
     if debug > 0:
-        print drawlist
+        print(drawlist)
 
     cNorm  = colors.Normalize(vmin=0, vmax=len(drawlist))
     jet = plt.get_cmap('jet')
     scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet)
     cs = []
     for i in range(len(drawlist)):
-	colorVal = scalarMap.to_rgba(i)
-	cs.append(colorVal)
+        colorVal = scalarMap.to_rgba(i)
+        cs.append(colorVal)
 
     xtime = []
     for t in sorted(tasks.keys()):
-	task = tasks[t]
-    	xtime.append(datetime.date(task.year, task.month, task.day))
+        task = tasks[t]
+        xtime.append(datetime.date(task.year, task.month, task.day))
     values = []
     for ti in drawlist:
-    	v = []
-	for t in sorted(tasks.keys()):
-	    task = tasks[t]
-    	    if task.nrecommended.has_key(ti):
-    		v.append(task.nrecommended[ti])
-    	    else:
-    		# v.append(None)
-    		v.append(0)
-	# print ti, v, len(v)
-    	values.append(v)
+        v = []
+        for t in sorted(tasks.keys()):
+            task = tasks[t]
+            if ti in task.nrecommended:
+                v.append(task.nrecommended[ti])
+            else:
+                # v.append(None)
+                v.append(0)
+        # print ti, v, len(v)
+        values.append(v)
 
     fig = plt.figure()
     ax = fig.add_subplot(111, projection='3d')
-    print drawlist
+    print(drawlist)
     for z in range(len(drawlist)):
-	xs = xtime
-	ys = values[z]
+        xs = xtime
+        ys = values[z]
 
-	# You can provide either a single color or an array. To demonstrate this,
-	# the first bar of each set will be colored cyan.
-	color = []
-	csz = cs[z]
-	for i in range(len(xtime)):
-	    if ys[i] > 0:
-		color.append(csz)
-	    else:
-		color.append((1.0, 1.0, 1.0, 0.0)) # how to make zero dependencies invisible ????
-	# col = [cs[z]] * len(xtime)
+        # You can provide either a single color or an array. To demonstrate this,
+        # the first bar of each set will be colored cyan.
+        color = []
+        csz = cs[z]
+        for i in range(len(xtime)):
+            if ys[i] > 0:
+                color.append(csz)
+            else:
+                color.append((1.0, 1.0, 1.0, 0.0)) # how to make zero dependencies invisible ????
+        # col = [cs[z]] * len(xtime)
         # setting width of bars:
-	#   http://stackoverflow.com/questions/886716/controling-bars-width-in-matplotlib-with-per-month-data
-	ax.bar(xtime, values[z], zs=z, zdir='y', color=color, alpha=0.8, width=90)
+        #   http://stackoverflow.com/questions/886716/controling-bars-width-in-matplotlib-with-per-month-data
+        ax.bar(xtime, values[z], zs=z, zdir='y', color=color, alpha=0.8, width=90)
 
     ax.set_yticklabels(drawlist)
     ax.set_xlabel('')

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list