]> git.decadent.org.uk Git - dak.git/commitdiff
rm822.py script to convert removals log into rfc822 format
authorLuca Falavigna <dktrkranz@franck.debian.org>
Sun, 1 Aug 2010 11:19:01 +0000 (11:19 +0000)
committerLuca Falavigna <dktrkranz@franck.debian.org>
Sun, 1 Aug 2010 11:19:01 +0000 (11:19 +0000)
Signed-off-by: Luca Falavigna <dktrkranz@franck.debian.org>
tools/rm822.py [new file with mode: 0755]

diff --git a/tools/rm822.py b/tools/rm822.py
new file mode 100755 (executable)
index 0000000..3fd9127
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+# (c) 2010 Luca Falavigna <dktrkranz@debian.org>
+# Free software licensed under the GPL version 2 or later
+
+import re
+from sys import argv
+
+if len(argv) < 2:
+    print 'Usage:\t./%s removal-file' % argv[0]
+    exit()
+fd = open(argv[1], 'r')
+data = fd.read()
+fd.close()
+removals = re.split('=\n=', data)
+for removal in removals:
+    removal = re.sub('\n\n', '\n', removal)
+    date = re.search('\[Date: (.*)\]\s\[', removal).group(1)
+    ftpmaster = re.search('\[ftpmaster: (.*)]', removal).group(1)
+    suite = re.search('from ([^:]+):', removal).group(1)
+    packages = re.split('from [\S\s]+:\n', removal)[1].split('\n---')[0]
+    reason = re.split('---\n', removal)[1].split('\n---')[0]
+    bug = re.search('Closed bugs: (\d+)', removal)
+    print 'Date: %s' % date
+    print 'Ftpmaster: %s' % ftpmaster
+    print 'Suite: %s' % suite
+    sources = []
+    binaries = []
+    for package in packages.split('\n'):
+        if package and not package.startswith('Closed bugs'):
+            for row in package.split('\n'):
+                element = row.split('|')
+                if element[2].find('source') > 0:
+                    sources.append(' %s_%s' % tuple(elem.strip(' ') for elem in element[:2]))
+                    element[2] = re.sub('source\s?,?', '', element[2]).strip(' ')
+                if len(element[2]):
+                    binaries.append(' %s_%s [%s]' % tuple(elem.strip(' ') for elem in element))
+    if len(sources):
+        print 'Sources:'
+        for source in sources:
+            print source
+    if len(binaries):
+        print 'Binaries:'
+        for binary in binaries:
+            print binary
+    print 'Reason: %s' % reason
+    if bug:
+        print 'Bug: %s' % bug.group(1)
+    print