From d6dda636b2f66e9794ba76af55255e3559cebc73 Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Sun, 1 Aug 2010 11:19:01 +0000 Subject: [PATCH] rm822.py script to convert removals log into rfc822 format Signed-off-by: Luca Falavigna --- tools/rm822.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 tools/rm822.py diff --git a/tools/rm822.py b/tools/rm822.py new file mode 100755 index 00000000..3fd91277 --- /dev/null +++ b/tools/rm822.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# (c) 2010 Luca Falavigna +# 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 -- 2.39.5