[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 21e2943ac77d0c349a804f44e53fec67179c7e6f
Author: Andreas Tille <tille at debian.org>
Date:   Wed May 18 09:39:21 2016 +0200

    Count and graph dependency based on json data created by blends-dev 0.7

diff --git a/misc/team_analysis_tools/count-dependencies.py b/misc/team_analysis_tools/count-dependencies.py
index 6b331ea..974c637 100755
--- a/misc/team_analysis_tools/count-dependencies.py
+++ b/misc/team_analysis_tools/count-dependencies.py
@@ -7,8 +7,7 @@ This script extracts numbers of dependencies of different metapackages of a Blen
 from __future__ import print_function
 
 from sys import stderr, exit, argv
-from os import listdir
-from os.path import isfile, exists
+from os import listdir, path
 from fnmatch import fnmatch
 import re
 from subprocess import Popen, PIPE
@@ -20,6 +19,7 @@ from mpl_toolkits.mplot3d import Axes3D
 import matplotlib.pyplot as plt
 import matplotlib.colors as colors
 import matplotlib.cm as cmx
+import json
 
 debug=0
 
@@ -30,11 +30,14 @@ DRAWTASKS = { 'med': ['bio', 'bio-dev', 'epi', 'practice', 'psychology'],
               'science': ['chemistry'], # ['astronomy'],   # 'dataacquisition', 'distributedcomputing', 'electronics', 'engineering'], 
               'debichem': [ 'abinitio', 'cheminformatics', 'modelling', 'molmech', 'polymer', 'semiempirical', 'view-edit-2d', 'visualisation' ],
             }
-SUPPRESSTASKS = { 'med': [ 'cloud' ],
+SUPPRESSTASKS = { 'med': [ 'cloud', 'bio-ngs', 'bio-phylogeny' ],
                   'science' : [],
                   'debichem' : [],
                 }
 
+changelog_entry_start_re = re.compile('^[^\s]+ \((\d.+)\) unstable; urgency=')
+changelog_entry_end_re   = re.compile('^ -- .* <.*@.*>  (.*)$')
+
 def TasksGetDrawList(tasks, checklist, avoidlist):
     try:
         task_last = tasks[sorted(tasks.keys())[-1]]
@@ -80,8 +83,7 @@ class taskscontent:
 
         if p not in self.recommends:
             self.recommends[p] = []
-        for r in recommends.encode('utf-8').split(','):
-            r = r.strip()
+        for r in recommends:
             # 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'):
@@ -100,21 +102,20 @@ class taskscontent:
 
 def main():
     if len(argv) < 3:
-        print("Usage: %s <path_to_svn_export_of_blends_repository> <blend>" % argv[0], file=stderr)
+        print("Usage: %s <path_to_blends_git_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)
+    root = argv[1]+'/dependency_data'
+    u_dirs = sorted(listdir(root))
 
     tasks = {}
     tasks_found = []
 
     # 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)
@@ -143,65 +144,61 @@ def main():
             else:
                 tasks[task.datekey] = task
 
-    for u in u_dirs:
-        if u == '.svn':
+    dversions={}
+    for ujson in u_dirs:
+        if not ujson.endswith('.json'):
+            print("Warning: File %s in dir %s ignored" % (ujson, root), file=stderr)
             continue
+        u = re.sub('^.+_(\d[.\d]*)\.json', '\\1', ujson)
         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
+        dversions[u] = {'jsondata': ujson,
+                       }
+    changelog = argv[1] + '/debian/changelog'
+    if not path.exists(changelog):
+        print("No such changelog %s" % changelog, file=stderr)
+        exit(1)
 
-        # 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("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("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("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']
+    f = open(changelog, 'r')
+#    for stanza in deb822.Sources.iter_paragraphs(f):
+#        print(stanza.keys()) # does not provide sensible keys ...
+
+    for line in f.readlines():
+        match = changelog_entry_start_re.match(line)
+        if match:
+            chversion = match.groups()[0]
+        match = changelog_entry_end_re.match(line)
+        if match:
+            chdate = DateFrom(match.groups()[0])
+            if chversion in dversions:
+                task = taskscontent(BLEND, chversion, chdate)
+                tasks[task.datekey] = task
+                # print(chversion, task.datekey)
+                dversions[chversion]['datekey'] = task.datekey
+                jfp=open(root+'/'+dversions[chversion]['jsondata'])
+                depdata=json.loads(jfp.read())
+                jfp.close()
+                dversions[chversion]['depdata'] = depdata
+
+#    print(dversions)
+
+                for package in depdata:
                     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
+                    recommends = depdata[package]['recommends']
+                    task.add_recommends(package,recommends)
+                    # in previous package versions we use Depends rather then Recommends
+                    if 'depends' in depdata[package]:
+                        depends = depdata[package]['depends']
+                        task.add_recommends(package,depends)
 
+    if debug > 0:
+        for t in tasks:
+            print("%s: %s" % (t, tasks[t]))
     if not tasks_found:
         print("No tasks found for Blend %s." % BLEND, file=stderr)
         exit()

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list