File: generate_credits.py

package info (click to toggle)
matplotlib 3.10.1%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 78,352 kB
  • sloc: python: 147,118; cpp: 62,988; objc: 1,679; ansic: 1,426; javascript: 786; makefile: 104; sh: 53
file content (89 lines) | stat: -rwxr-xr-x 2,511 bytes parent folder | download | duplicates (3)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
#
# This script generates credits.rst with an up-to-date list of contributors
# to the matplotlib github repository.

from collections import Counter
import locale
import re
import subprocess

TEMPLATE = """.. Note: This file is auto-generated using generate_credits.py

.. _credits:

*******
Credits
*******


Matplotlib was written by John D. Hunter, with contributions from an
ever-increasing number of users and developers.  The current lead developer is
Thomas A. Caswell, who is assisted by many `active developers
<https://www.openhub.net/p/matplotlib/contributors>`_.
Please also see our instructions on :doc:`/citing`.

The following is a list of contributors extracted from the
git revision control history of the project:

{contributors}

Some earlier contributors not included above are (with apologies
to any we have missed):

Charles Twardy,
Gary Ruben,
John Gill,
David Moore,
Paul Barrett,
Jared Wahlstrand,
Jim Benson,
Paul Mcguire,
Andrew Dalke,
Nadia Dencheva,
Baptiste Carvello,
Sigve Tjoraand,
Ted Drain,
James Amundson,
Daishi Harada,
Nicolas Young,
Paul Kienzle,
John Porter,
and Jonathon Taylor.

Thanks to Tony Yu for the original logo design.

We also thank all who have reported bugs, commented on
proposed changes, or otherwise contributed to Matplotlib's
development and usefulness.
"""


def check_duplicates():
    text = subprocess.check_output(['git', 'shortlog', '--summary', '--email'])
    lines = text.decode('utf8').split('\n')
    contributors = [line.split('\t', 1)[1].strip() for line in lines if line]
    emails = [re.match('.*<(.*)>', line).group(1) for line in contributors]
    email_counter = Counter(emails)

    if email_counter.most_common(1)[0][1] > 1:
        print('DUPLICATE CHECK: The following email addresses are used with '
              'more than one name.\nConsider adding them to .mailmap.\n')
        for email, count in email_counter.items():
            if count > 1:
                print('{}\n{}'.format(
                    email, '\n'.join(l for l in lines if email in l)))


def generate_credits():
    text = subprocess.check_output(['git', 'shortlog', '--summary'])
    lines = text.decode('utf8').split('\n')
    contributors = [line.split('\t', 1)[1].strip() for line in lines if line]
    contributors.sort(key=locale.strxfrm)
    with open('credits.rst', 'w') as f:
        f.write(TEMPLATE.format(contributors=',\n'.join(contributors)))


if __name__ == '__main__':
    check_duplicates()
    generate_credits()