-
Notifications
You must be signed in to change notification settings - Fork 287
/
paper_author_list.py
executable file
·71 lines (59 loc) · 1.86 KB
/
paper_author_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""Generate an author list for a new paper or abstract."""
import json
import sys
from pathlib import Path
from update_zenodo import get_git_lines, sort_contributors
# These authors should go last
AUTHORS_LAST = ['Gorgolewski, Krzysztof J.', 'Poldrack, Russell A.', 'Esteban, Oscar']
def _aslist(inlist):
if not isinstance(inlist, list):
return [inlist]
return inlist
if __name__ == '__main__':
devs = json.loads(Path('.maint/developers.json').read_text())
contribs = json.loads(Path('.maint/contributors.json').read_text())
author_matches, unmatched = sort_contributors(
devs + contribs,
get_git_lines(),
exclude=json.loads(Path('.maint/former.json').read_text()),
last=AUTHORS_LAST,
)
# Remove position
affiliations = []
for item in author_matches:
del item['position']
for a in _aslist(item.get('affiliation', 'Unaffiliated')):
if a not in affiliations:
affiliations.append(a)
aff_indexes = [
', '.join(
[
'%d' % (affiliations.index(a) + 1)
for a in _aslist(author.get('affiliation', 'Unaffiliated'))
]
)
for author in author_matches
]
print(
'Some people made commits, but are missing in .maint/ files: {}.'.format(
', '.join(unmatched)
),
file=sys.stderr,
)
print('Authors (%d):' % len(author_matches))
print(
'{}.'.format(
'; '.join(
[
rf'{i["name"]} \ :sup:`{idx}`\ '
for i, idx in zip(author_matches, aff_indexes, strict=False)
]
)
)
)
print(
'\n\nAffiliations:\n{}'.format(
'\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
)
)