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

filippo at alioth.debian.org filippo at alioth.debian.org
Sun Jul 27 12:02:39 UTC 2008


Author: filippo
Date: 2008-07-27 12:02:38 +0000 (Sun, 27 Jul 2008)
New Revision: 944

Modified:
   upload-history/munge_ddc.py
Log:
normalize date, invoke gpgv with env LC_ALL=C


Modified: upload-history/munge_ddc.py
===================================================================
--- upload-history/munge_ddc.py	2008-07-27 11:57:57 UTC (rev 943)
+++ upload-history/munge_ddc.py	2008-07-27 12:02:38 UTC (rev 944)
@@ -2,6 +2,8 @@
 # extract upload info from a debian-devel-changes mailbox file
 
 import email
+#lowercased in 2.5
+import email.Utils as emailutils
 import mailbox
 import re
 import rfc822
@@ -46,7 +48,7 @@
         return ("N/A", "N/A")
 
     p = subprocess.Popen(opts, stdin=subprocess.PIPE, stderr=subprocess.PIPE,
-            stdout=subprocess.PIPE)
+            stdout=subprocess.PIPE, env={"LC_ALL": "C"} )
 
     (out, err) = p.communicate("\n".join(msg))
     
@@ -60,6 +62,18 @@
     else:
         return ("N/A", "N/A")
 
+def normalize_date(date):
+    d = emailutils.parsedate_tz(date)
+    if not d:
+        return None
+    
+    try:
+        ret = emailutils.formatdate(emailutils.mktime_tz(d), True)
+    except OverflowError:
+        ret = None
+
+    return ret
+
 # XXX factor this to work with plain .changes
 def munge_ddc(mb_file, outfile=sys.stdout):
     """ Scan given mb_file as a unix mailbox and extract upload informations """
@@ -113,14 +127,18 @@
 
         (c['Key'], c['Signed-By']) = extract_pgp(body)
 
-        # unparsable date, use the one from mail message
-        if not rfc822.parsedate_tz(c['Date']):
-            if rfc822.parsedate_tz(msg['Date']):
-                c['Date'] = msg['Date']
-            # this shouldn't really happen
-            else:
-                del c['Date']
+        # 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']
+        else:
+            c['Date'] = d
 
+        # finally output fields
         for field in 'Source', 'Version', 'Date', 'Changed-By', 'Maintainer', 'NMU', 'Key', 'Signed-By':
             try:
                 print "%s: %s" % (field, c[field])




More information about the Collab-qa-commits mailing list