rm822.py 1.8 KB

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