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

filippo at alioth.debian.org filippo at alioth.debian.org
Sun Oct 5 08:33:19 UTC 2008


Author: filippo
Date: 2008-10-05 08:33:18 +0000 (Sun, 05 Oct 2008)
New Revision: 1319

Added:
   upload-history/extract_changes.py
Log:
script to extract changes file from mailboxes

Added: upload-history/extract_changes.py
===================================================================
--- upload-history/extract_changes.py	                        (rev 0)
+++ upload-history/extract_changes.py	2008-10-05 08:33:18 UTC (rev 1319)
@@ -0,0 +1,44 @@
+#!/usr/bin/python2.4
+# extract unprocessed .changes from unix mailboxes
+
+import email
+#lowercased in 2.5
+import email.Utils as emailutils
+import mailbox
+import re
+import rfc822
+import subprocess
+import sys
+import os
+import cPickle
+
+from os.path import basename
+from debian_bundle import deb822
+
+def extract_changes(mb_file, outfile=sys.stdout):
+    mb = mailbox.PortableUnixMailbox(file(mb_file), factory=email.message_from_file)
+
+    for msg in mb:
+        if msg.is_multipart():
+            continue
+        
+        body = msg.get_payload(decode=True).split('\n')
+        
+# XXX work around Hash: sha1(\n)+ at the beginning of signed body
+        for (i,l) in enumerate(body):
+            if l.startswith("Format:"):
+                break
+
+        c = deb822.Changes(body[i:])
+        outfile.write(str(c))
+        outfile.write("\n")
+
+if __name__ == '__main__':
+    if len(sys.argv) < 2:
+        print "usage: file1 .. fileN"
+        sys.exit(1)
+
+    for f in sys.argv[1:]:
+        extract_changes(f)
+
+# vim: et:ts=4:sw=4


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




More information about the Collab-qa-commits mailing list