rm822.py 1.6 KB

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