forked from psychopy/psychopy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen_authors.py
53 lines (41 loc) · 1.45 KB
/
gen_authors.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Regenerate AUTHORS.md
"""
from __future__ import absolute_import, print_function
import os
import codecs
import warnings
from datetime import datetime
from psychopy.core import shellCall
repo_path = os.path.split(__file__)[0]
authors_path = os.path.join(repo_path, 'AUTHORS.md')
git_command = 'git --no-pager shortlog -s HEAD %s' % repo_path
last_run = datetime.utcnow().strftime('%B %d, %Y')
authors_header = """Authors
-------
**PsychoPy is developed through community effort.**
The project was created and is maintained by Jonathan Peirce.
The following individuals have contributed code or documentation to
PsychoPy:\n
"""
do_not_edit_note = """
---
*This list was auto-generated via `gen_authors.py`. Do not edit manually.*\n
*Last updated on %s (UTC).*
""" % last_run
if __name__ == '__main__':
short_log = shellCall(git_command)
authors = []
for line in short_log.splitlines():
contributions, author = tuple(line.split('\t'))
if author != 'unknown':
authors.append(author)
else:
msg = ('Unknown author found and skipped; please revise the output '
'of `git shortlog -se` and consider amending .mailmap')
warnings.warn(msg)
with codecs.open(authors_path, 'w', encoding='utf-8') as f:
f.write(authors_header)
f.writelines(['* %s\n' % author for author in authors])
f.write(do_not_edit_note)