PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/pypy/doc/tool/makecontributor.py

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