PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/pypy/doc/tool/makecontributor.py

https://bitbucket.org/kcr/pypy
Python | 133 lines | 127 code | 6 blank | 0 comment | 7 complexity | 9a11e176d60250870dffc7f7f7eea796 MD5 | raw file
Possible License(s): Apache-2.0
  1. import py
  2. import sys
  3. from collections import defaultdict
  4. import operator
  5. import re
  6. import mercurial.localrepo
  7. import mercurial.ui
  8. ROOT = py.path.local(__file__).join('..', '..', '..', '..')
  9. author_re = re.compile('(.*) <.*>')
  10. pair_programming_re = re.compile(r'^\((.*?)\)')
  11. excluded = set(["pypy", "convert-repo"])
  12. alias = {
  13. 'Anders Chrigstrom': ['arre'],
  14. 'Antonio Cuni': ['antocuni', 'anto'],
  15. 'Armin Rigo': ['arigo', 'arfigo', 'armin', 'arigato'],
  16. 'Maciej Fijalkowski': ['fijal'],
  17. 'Carl Friedrich Bolz': ['cfbolz', 'cf'],
  18. 'Samuele Pedroni': ['pedronis', 'samuele', 'samule'],
  19. 'Michael Hudson': ['mwh'],
  20. 'Holger Krekel': ['hpk', 'holger krekel', 'holger', 'hufpk'],
  21. "Amaury Forgeot d'Arc": ['afa'],
  22. 'Alex Gaynor': ['alex', 'agaynor'],
  23. 'David Schneider': ['bivab', 'david'],
  24. 'Christian Tismer': ['chris', 'christian', 'tismer',
  25. 'tismer@christia-wjtqxl.localdomain'],
  26. 'Benjamin Peterson': ['benjamin'],
  27. 'Hakan Ardo': ['hakan', 'hakanardo'],
  28. 'Niklaus Haldimann': ['nik'],
  29. 'Alexander Schremmer': ['xoraxax'],
  30. 'Anders Hammarquist': ['iko'],
  31. 'David Edelsohn': ['edelsoh', 'edelsohn'],
  32. 'Niko Matsakis': ['niko'],
  33. 'Jakub Gustak': ['jlg'],
  34. 'Guido Wesdorp': ['guido'],
  35. 'Michael Foord': ['mfoord'],
  36. 'Mark Pearse': ['mwp'],
  37. 'Toon Verwaest': ['tverwaes'],
  38. 'Eric van Riet Paap': ['ericvrp'],
  39. 'Jacob Hallen': ['jacob', 'jakob'],
  40. 'Anders Lehmann': ['ale', 'anders'],
  41. 'Bert Freudenberg': ['bert'],
  42. 'Boris Feigin': ['boris', 'boria'],
  43. 'Valentino Volonghi': ['valentino', 'dialtone'],
  44. 'Aurelien Campeas': ['aurelien', 'aureliene'],
  45. 'Adrien Di Mascio': ['adim'],
  46. 'Jacek Generowicz': ['Jacek', 'jacek'],
  47. 'Jim Hunziker': ['landtuna@gmail.com'],
  48. 'Kristjan Valur Jonsson': ['kristjan@kristjan-lp.ccp.ad.local'],
  49. 'Laura Creighton': ['lac'],
  50. 'Aaron Iles': ['aliles'],
  51. 'Ludovic Aubry': ['ludal', 'ludovic'],
  52. 'Lukas Diekmann': ['l.diekmann', 'ldiekmann'],
  53. 'Matti Picus': ['Matti Picus matti.picus@gmail.com',
  54. 'matthp', 'mattip', 'mattip>'],
  55. 'Michael Cheng': ['mikefc'],
  56. 'Richard Emslie': ['rxe'],
  57. 'Roberto De Ioris': ['roberto@goyle'],
  58. 'Roberto De Ioris': ['roberto@mrspurr'],
  59. 'Sven Hager': ['hager'],
  60. 'Tomo Cocoa': ['cocoatomo'],
  61. }
  62. alias_map = {}
  63. for name, nicks in alias.iteritems():
  64. for nick in nicks:
  65. alias_map[nick] = name
  66. def get_canonical_author(name):
  67. match = author_re.match(name)
  68. if match:
  69. name = match.group(1)
  70. return alias_map.get(name, name)
  71. ignored_nicknames = defaultdict(int)
  72. def get_more_authors(log):
  73. match = pair_programming_re.match(log)
  74. if not match:
  75. return set()
  76. ignore_words = ['around', 'consulting', 'yesterday', 'for a bit', 'thanks',
  77. 'in-progress', 'bits of', 'even a little', 'floating',]
  78. sep_words = ['and', ';', '+', '/', 'with special by']
  79. nicknames = match.group(1)
  80. for word in ignore_words:
  81. nicknames = nicknames.replace(word, '')
  82. for word in sep_words:
  83. nicknames = nicknames.replace(word, ',')
  84. nicknames = [nick.strip().lower() for nick in nicknames.split(',')]
  85. authors = set()
  86. for nickname in nicknames:
  87. author = alias_map.get(nickname)
  88. if not author:
  89. ignored_nicknames[nickname] += 1
  90. else:
  91. authors.add(author)
  92. return authors
  93. def main(show_numbers):
  94. ui = mercurial.ui.ui()
  95. repo = mercurial.localrepo.localrepository(ui, str(ROOT))
  96. authors_count = defaultdict(int)
  97. for i in repo:
  98. ctx = repo[i]
  99. authors = set()
  100. authors.add(get_canonical_author(ctx.user()))
  101. authors.update(get_more_authors(ctx.description()))
  102. for author in authors:
  103. if author not in excluded:
  104. authors_count[author] += 1
  105. # uncomment the next lines to get the list of nicknamed which could not be
  106. # parsed from commit logs
  107. ## items = ignored_nicknames.items()
  108. ## items.sort(key=operator.itemgetter(1), reverse=True)
  109. ## for name, n in items:
  110. ## if show_numbers:
  111. ## print '%5d %s' % (n, name)
  112. ## else:
  113. ## print name
  114. items = authors_count.items()
  115. items.sort(key=operator.itemgetter(1), reverse=True)
  116. for name, n in items:
  117. if show_numbers:
  118. print '%5d %s' % (n, name)
  119. else:
  120. print name
  121. if __name__ == '__main__':
  122. show_numbers = '-n' in sys.argv
  123. main(show_numbers)