rm822.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/python
  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. fd = open(argv[1], 'r')
  10. data = fd.read()
  11. fd.close()
  12. removals = re.split('=\n=', data)
  13. for removal in removals:
  14. removal = re.sub('\n\n', '\n', removal)
  15. date = re.search('\[Date: (.*)\]\s\[', removal).group(1)
  16. ftpmaster = re.search('\[ftpmaster: (.*)]', removal).group(1)
  17. suite = re.search('from ([^:]+):', removal).group(1)
  18. packages = re.split('from [\S\s]+:\n', removal)[1].split('\n---')[0]
  19. reason = re.split('---\n', removal)[1].split('\n---')[0]
  20. bug = re.search('Closed bugs: (\d+)', removal)
  21. print 'Date: %s' % date
  22. print 'Ftpmaster: %s' % ftpmaster
  23. print 'Suite: %s' % suite
  24. sources = []
  25. binaries = []
  26. for package in packages.split('\n'):
  27. if package and not package.startswith('Closed bugs'):
  28. for row in package.split('\n'):
  29. element = row.split('|')
  30. if element[2].find('source') > 0:
  31. sources.append(' %s_%s' % tuple(elem.strip(' ') for elem in element[:2]))
  32. element[2] = re.sub('source\s?,?', '', element[2]).strip(' ')
  33. if element[2]:
  34. binaries.append(' %s_%s [%s]' % tuple(elem.strip(' ') for elem in element))
  35. if sources:
  36. print 'Sources:'
  37. for source in sources:
  38. print source
  39. if binaries:
  40. print 'Binaries:'
  41. for binary in binaries:
  42. print binary
  43. print 'Reason: %s' % reason.replace('\n', '\n ')
  44. if bug:
  45. print 'Bug: %s' % bug.group(1)
  46. print