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

filippo at alioth.debian.org filippo at alioth.debian.org
Wed Aug 13 17:11:02 UTC 2008


Author: filippo
Date: 2008-08-13 17:11:01 +0000 (Wed, 13 Aug 2008)
New Revision: 1092

Modified:
   upload-history/munge_ddc.py
Log:
sanitize Closes:, rework some names

Modified: upload-history/munge_ddc.py
===================================================================
--- upload-history/munge_ddc.py	2008-08-13 09:32:13 UTC (rev 1091)
+++ upload-history/munge_ddc.py	2008-08-13 17:11:01 UTC (rev 1092)
@@ -25,8 +25,12 @@
 #keyid_RE = re.compile("Signature made (.+) using \S+ key ID (\S+)")
 keyid_RE = re.compile("\[GNUPG:\] (GOOD|BAD|ERR)SIG (\S+) (.+)")
 
+bugnumber_list_RE = re.compile("^([0-9]{3,} ?)+")
+
 def extract_pgp(msg, keyring=["/usr/share/keyrings/debian-keyring.gpg",
-                              "/usr/share/keyrings/debian-maintainers.gpg"]):
+                              "/usr/share/keyrings/debian-maintainers.gpg",
+                              "./debian-keyring.gpg",
+                              "./debian-maintainers.gpg"]):
     """ Verify given msg with gpgv using the given (list of) keyring(s)
     
     Return a tuple (key, key-id) or ("N/A", "N/A") if key not available"""
@@ -108,11 +112,12 @@
 
         c = deb822.Changes(body[i:])
 
-        required = set(['Source', 'Architecture', 'Version', 'Changes'])
-        found = set(c.keys())
+        required_fields = set(['Source', 'Architecture', 'Version', 'Changes'])
+        output_fields = ['Source', 'Architecture', 'Version', 'Date', 'Changed-By', 'Maintainer', 'NMU', 'Closes', 'Key', 'Signed-By']
+        found_fields = set(c.keys())
         
-        if not required.issubset(found):
-            sys.stderr.write("%s %s fields not found: %s\n" % (mb_file, msg['Subject'], " ".join(required.difference(found))))
+        if not required_fields.issubset(found_fields):
+            sys.stderr.write("%s %s fields not found: %s\n" % (mb_file, msg['Subject'], " ".join(required_fields.difference(found_fields))))
             sys.stderr.write("%s" % "\n".join(c))
             continue
 
@@ -127,19 +132,25 @@
 
         (c['Key'], c['Signed-By']) = extract_pgp(body)
 
+        ### Fields sanitization
+
         # try first with changes date, then message date
         d = normalize_date(c['Date'])
         if not d:
             d = normalize_date(msg['Date'])
-        
         # unparsable date, make it N/A
         if not d:
-            del c['Date']
+            c['Date'] = "N/A"
         else:
             c['Date'] = d
 
+        if c.has_key('Closes'):
+            m = bugnumber_list_RE.match(c['Closes'])
+            if not m:
+                c['Closes'] = "N/A"
+
         # finally output fields
-        for field in 'Source', 'Version', 'Date', 'Architecture', 'Changed-By', 'Maintainer', 'NMU', 'Closes', 'Key', 'Signed-By':
+        for field in output_fields:
             try:
                 print "%s: %s" % (field, c[field])
             except KeyError:




More information about the Collab-qa-commits mailing list