[Collab-qa-commits] r617 - upload-history

filippo at alioth.debian.org filippo at alioth.debian.org
Thu Dec 27 12:03:49 UTC 2007


Author: filippo
Date: 2007-12-27 12:03:48 +0000 (Thu, 27 Dec 2007)
New Revision: 617

Added:
   upload-history/mbox_to_csv.py
Log:
script to parse d-d-changes instead of queue/done

Added: upload-history/mbox_to_csv.py
===================================================================
--- upload-history/mbox_to_csv.py	                        (rev 0)
+++ upload-history/mbox_to_csv.py	2007-12-27 12:03:48 UTC (rev 617)
@@ -0,0 +1,73 @@
+#!/usr/bin/python2.4
+
+import email
+import sys
+import mailbox
+import re
+import rfc822
+
+from debian_bundle import deb822
+
+# XXX gives false positives for example with -x+y.z.w, mitigated by checking Changes also
+nmu_version_RE = re.compile("-\S+\.\d+$")
+nmu_changelog_RE = re.compile("\s+\*\s+.*(NMU|non[- ]maintainer)", re.IGNORECASE + re.MULTILINE)
+
+def mbox_to_csv( mb_file ):
+    outfile = file(mb_file + ".csv", 'w')
+    
+    mb = mailbox.PortableUnixMailbox(file(mb_file), factory=email.message_from_file)
+
+    for msg in mb:
+        assert msg.is_multipart() == False
+        
+        body = msg.get_payload().split('\n')
+
+        is_nmu = False
+        c = deb822.Changes(body)
+        
+        print "processing: " + c['Source']
+
+        try:
+            if not 'source' in c['Architecture']:
+                print "  source not in architecture"
+                continue
+        except KeyError:
+            print "  source not in architecture"
+            continue
+        
+        try:
+           nmu_version = nmu_version_RE.search(c['Version'])
+        except KeyError:
+           print "  no version"
+           continue
+
+        try:
+           nmu_changes = nmu_changelog_RE.search(c['Changes'])
+        except KeyError:
+           print "  no changes"
+           pass
+        #   logfile.write(fname + " no changes NMU not detected\n")
+        
+        is_nmu = ((nmu_version is not None) and (nmu_changes is not None))
+
+        try:
+            unixtime = int(rfc822.mktime_tz(rfc822.parsedate_tz(c['Date'])))
+        except KeyError:
+            print "  no date"
+            continue
+
+        if not c.has_key('Changed-By'):
+            c['Changed-By'] = ""
+
+        try:
+            outfile.write("%s|%s|%s|%s|%s|%s\n" % (c['Source'], c['Version'], unixtime, c['Maintainer'], c['Changed-By'], is_nmu))
+        except KeyError:
+            print "  not printing"
+            continue
+
+if __name__ == '__main__':
+    if len(sys.argv) < 2:
+        print "Filename argument required"
+        sys.exit(1)
+
+    mbox_to_csv(sys.argv[1])


Property changes on: upload-history/mbox_to_csv.py
___________________________________________________________________
Name: svn:executable
   + *




More information about the Collab-qa-commits mailing list