]> git.decadent.org.uk Git - dak.git/blob - tools/rm822.py
LOCAL: Remove replay check
[dak.git] / tools / rm822.py
1 #!/usr/bin/python
2 # (c) 2010 Luca Falavigna <dktrkranz@debian.org>
3 # Free software licensed under the GPL version 2 or later
4
5 import re
6 from sys import argv
7
8 if len(argv) < 2:
9     print 'Usage:\t./%s removal-file' % argv[0]
10     exit()
11 fd = open(argv[1], 'r')
12 data = fd.read()
13 fd.close()
14 removals = re.split('=\n=', data)
15 for removal in removals:
16     removal = re.sub('\n\n', '\n', removal)
17     date = re.search('\[Date: (.*)\]\s\[', removal).group(1)
18     ftpmaster = re.search('\[ftpmaster: (.*)]', removal).group(1)
19     suite = re.search('from ([^:]+):', removal).group(1)
20     packages = re.split('from [\S\s]+:\n', removal)[1].split('\n---')[0]
21     reason = re.split('---\n', removal)[1].split('\n---')[0]
22     bug = re.search('Closed bugs: (\d+)', removal)
23     print 'Date: %s' % date
24     print 'Ftpmaster: %s' % ftpmaster
25     print 'Suite: %s' % suite
26     sources = []
27     binaries = []
28     for package in packages.split('\n'):
29         if package and not package.startswith('Closed bugs'):
30             for row in package.split('\n'):
31                 element = row.split('|')
32                 if element[2].find('source') > 0:
33                     sources.append(' %s_%s' % tuple(elem.strip(' ') for elem in element[:2]))
34                     element[2] = re.sub('source\s?,?', '', element[2]).strip(' ')
35                 if element[2]:
36                     binaries.append(' %s_%s [%s]' % tuple(elem.strip(' ') for elem in element))
37     if sources:
38         print 'Sources:'
39         for source in sources:
40             print source
41     if binaries:
42         print 'Binaries:'
43         for binary in binaries:
44             print binary
45     print 'Reason: %s' % reason.replace('\n', '\n ')
46     if bug:
47         print 'Bug: %s' % bug.group(1)
48     print