sortChanges.py 810 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/python
  2. import re
  3. import sys
  4. def fetch(fn):
  5. with open(fn) as f:
  6. s = f.read()
  7. s = "%s\n" % s.rstrip()
  8. return s
  9. def score(s):
  10. m = re.match(r'^ +o (.*)', s)
  11. if not m:
  12. print >>sys.stderr, "Can't score %r"%s
  13. lw = m.group(1).lower()
  14. if lw.startswith("major feature"):
  15. score = 0
  16. elif lw.startswith("major bug"):
  17. score = 1
  18. elif lw.startswith("major"):
  19. score = 2
  20. elif lw.startswith("minor feature"):
  21. score = 10
  22. elif lw.startswith("minor bug"):
  23. score = 11
  24. elif lw.startswith("minor"):
  25. score = 12
  26. else:
  27. score = 100
  28. return (score, lw, s)
  29. changes = [ score(fetch(fn)) for fn in sys.argv[1:] if not fn.endswith('~') ]
  30. changes.sort()
  31. for _, _, s in changes:
  32. print s