Debian Codegraph @

pypy/doc/tool/makecontributor.py

raw symbols SCIP
1 # encoding: utf-8
2 from __future__ import print_function
3 # NOTE: run this script with LANG=en_US.UTF-8
4
5 import sys
6 from collections import defaultdict
7 import operator
8 import re
9 import subprocess
10
11 author_re = re.compile('(.*) <.*>')
12 pair_programming_re = re.compile(r'^\((.*?)\)')
13 excluded = set(["pypy", "convert-repo", "hgattic", 'Miss Islington (bot)',
14 "remote-hg", "Unknown"])
15
16 alias = {
17 'Anders Chrigstrom': ['arre'],
18 'Antonio Cuni': ['antocuni', 'anto', 'antonio'],
19 'Armin Rigo': ['arigo', 'arfigo', 'armin', 'arigato'],
20 'Maciej Fijałkowski': ['fijal', 'Maciej Fijalkowski'],
21 'Carl Friedrich Bolz-Tereick': ['Carl Friedrich Bolz', 'cfbolz', 'cf',
22 'cbolz', 'CF Bolz-Tereick'],
23 'Samuele Pedroni': ['pedronis', 'samuele', 'samule'],
24 'Richard Plangger': ['planrich', 'plan_rich'],
25 'Remi Meier': ['remi'],
26 'Michael Hudson-Doyle': ['mwh', 'Michael Hudson', 'michaelh'],
27 'Holger Krekel': ['hpk', 'holger krekel', 'holger', 'hufpk'],
28 "Amaury Forgeot d'Arc": ['afa', '[email protected]', 'amaury'],
29 'Alex Gaynor': ['alex', 'agaynor'],
30 'David Schneider': ['bivab', 'david'],
31 'Christian Tismer': ['chris', 'christian', 'tismer',
32 '[email protected]'],
33 'Benjamin Peterson': ['benjamin'],
34 'Håkan Ardö': ['hakan', 'hakanardo', 'Hakan Ardo'],
35 'Niklaus Haldimann': ['nik'],
36 'Alexander Schremmer': ['xoraxax'],
37 'Anders Hammarquist': ['iko'],
38 'David Edelsohn': ['edelsoh', 'edelsohn','opassembler.py'],
39 'Niko Matsakis': ['niko'],
40 'Jakub Gustak': ['jlg'],
41 'Guido Wesdorp': ['guido'],
42 'Michael Foord': ['mfoord'],
43 'Mark Pearse': ['mwp'],
44 'Eric van Riet Paap': ['ericvrp'],
45 'Jacob Hallen': ['jacob', 'jakob', 'jacob hallen'],
46 'Anders Lehmann': ['ale', 'anders'],
47 'Vanessa Freudenberg': ['bert', 'Bert Freudenberg'],
48 'Boris Feigin': ['boris', 'boria'],
49 'Valentino Volonghi': ['valentino', 'dialtone'],
50 'Aurelien Campeas': ['aurelien', 'aureliene'],
51 'Adrien Di Mascio': ['adim'],
52 'Jacek Generowicz': ['Jacek', 'jacek'],
53 'Jim Hunziker': ['[email protected]'],
54 'Kristjan Valur Jonsson': ['[email protected]'],
55 'Laura Creighton': ['lac'],
56 'Aaron Iles': ['aliles'],
57 'Ludovic Aubry': ['ludal', 'ludovic'],
58 'Lukas Diekmann': ['l.diekmann', 'ldiekmann'],
59 'Matti Picus': ['Matti Picus [email protected]',
60 'matthp', 'mattip', 'mattip>', 'matti'],
61 'Michael Cheng': ['mikefc'],
62 'Richard Emslie': ['rxe'],
63 'Roberto De Ioris': ['roberto@goyle','roberto@mrspurr'],
64 'Sven Hager': ['hager'],
65 'Tomo Cocoa': ['cocoatomo'],
66 'Romain Guillebert': ['rguillebert', 'rguillbert', 'romain', 'Guillebert Romain'],
67 'Ronan Lamy': ['ronan'],
68 'Edd Barrett': ['edd'],
69 'Manuel Jacob': ['mjacob'],
70 'Rami Chowdhury': ['necaris'],
71 'Stanislaw Halik': ['Stanislaw Halik', 'w31rd0'],
72 'Wenzhu Man': ['wenzhu man', 'wenzhuman'],
73 'Anton Gulenko': ['anton gulenko', 'anton_gulenko'],
74 'Richard Lancaster': ['richardlancaster'],
75 'William Leslie': ['William ML Leslie'],
76 'Spenser Bauman': ['Spenser Andrew Bauman'],
77 'Raffael Tfirst': ['[email protected]'],
78 'timo': ['[email protected]'],
79 'Jasper Schulz': ['Jasper.Schulz', 'jbs'],
80 'Aaron Gallagher': ['"Aaron Gallagher'],
81 'Yasir Suhail': ['yasirs'],
82 'Squeaky': ['squeaky'],
83 "Dodan Mihai": ['[email protected]'],
84 'Wim Lavrijsen': ['wlav'],
85 'Toon Verwaest': ['toon', 'tverwaes'], #
86 'Seo Sanghyeon': ['sanxiyn'],
87 'Leonardo Santagada': ['santagada'],
88 'Laurence Tratt': ['ltratt'],
89 'Pieter Zieschang': ['pzieschang', '[email protected]'],
90 'John Witulski': ['witulski'],
91 'Andrew Lawrence': ['[email protected]', 'andrewjlawrence'],
92 'Batuhan Taskaya': ['isidentical'],
93 'Ondrej Baranovič': ['nulano', 'Nulano'],
94 'Brad Kish': ['rtkbkish'],
95 'Michał Górny': ['mgorny'],
96 'David Hewitt': ['davidhewitt'],
97 'Adrian Kuhn': ['akuhn'],
98 'David Malcolm': ['dmalcolm'],
99 'Simon Cross': ['hodgestar'],
100 'Łukasz Langa': ['ambv'],
101 'Wenzel Jakob': ['Jakob Wenzel'],
102 'Maxwell Bernstein': ['Max Bernstein'],
103 'Paul Gey': ['narpfel'],
104 'Bartosz Skowron': ['getxsick'],
105 'Beatrice During': ['bea'],
106 'Mikael Schönenberg': ['micke'],
107 'Oscar Nierstrasz': ['oscar'],
108 'Tim Felgentreff': ['timfel'],
109 'Tadeu Zagallo': ['tadeuzagallo'],
110 'Pierre Augier': ['paugier'],
111 'Julian Waters': ['TheShermanTanker'],
112 }
113
114 alias_map = {}
115 for name, nicks in alias.items():
116 for nick in nicks:
117 alias_map[nick] = name
118
119 def get_canonical_author(name):
120 match = author_re.match(name)
121 if match:
122 name = match.group(1)
123 return alias_map.get(name, name)
124
125 ignored_nicknames = defaultdict(int)
126
127 def get_more_authors(log):
128 match = pair_programming_re.match(log)
129 if not match:
130 return set()
131 ignore_words = ['around', 'consulting', 'yesterday', 'for a bit', 'thanks',
132 'in-progress', 'bits of', 'even a little', 'floating',
133 'a bit', 'reviewing', 'looking', 'advising', 'partly', 'ish',
134 'watching', 'mostly', 'jumping', 'twitch', 's390x']
135 sep_words = ['and', ';', '+', '/', 'with special by']
136 nicknames = match.group(1)
137 for word in ignore_words:
138 nicknames = nicknames.replace(word, '')
139 for word in sep_words:
140 nicknames = nicknames.replace(word, ',')
141 nicknames = [nick.strip().lower() for nick in nicknames.split(',')]
142 authors = set()
143 for nickname in nicknames:
144 if not nickname:
145 continue
146 author = alias_map.get(nickname)
147 if not author:
148 ignored_nicknames[nickname] += 1
149 else:
150 authors.add(author)
151 return authors
152
153 def main(show_numbers):
154 txt = subprocess.check_output(["git", "log", "--all", "--no-merges", '--format="%aN#<%aE>#%s"'], text=True)
155 authors_count = defaultdict(int)
156 with open("/tmp/authors", "wt", encoding="utf8") as fid:
157 fid.write(txt)
158 for line in txt.split('\n'):
159 if "#" not in line:
160 continue
161 if "#Notes added by" in line:
162 continue
163 author_src, author_mail, description = line.strip('"').split("#", 2)
164 authors = set()
165 authors.add(get_canonical_author(author_src))
166 authors.update(get_more_authors(description))
167 for author in authors:
168 if author not in excluded:
169 authors_count[author] += 1
170
171 # enable the next lines to get the list of nicknamed which could not be
172 # parsed from description
173 if 0:
174 items = list(ignored_nicknames.items())
175 items.sort(key=operator.itemgetter(1), reverse=True)
176 for name, n in items:
177 if show_numbers:
178 print("%5d '%s'" % (n, name))
179 else:
180 print("'%s'" % name)
181 return
182
183 items = list(authors_count.items())
184 items.sort(key=operator.itemgetter(1), reverse=True)
185 for name, n in items:
186 if show_numbers:
187 print('%5d %s' % (n, name))
188 else:
189 print(' ' + name)
190
191 if __name__ == '__main__':
192 show_numbers = '-n' in sys.argv
193 main(show_numbers)