File: update_authors.py

package info (click to toggle)
psychopy 2020.2.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 44,056 kB
  • sloc: python: 119,649; javascript: 3,022; makefile: 148; sh: 125; xml: 9
file content (54 lines) | stat: -rw-r--r-- 1,493 bytes parent folder | download | duplicates (2)
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
#!/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
from pathlib import Path

repo_path = Path(__file__).parent.parent
authors_path = 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)