summaryrefslogtreecommitdiff
path: root/tools/team_list.py
blob: ce2c27162332f8df59de3fad3d35039a9705e8c0 (plain)
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
import os
import sys
import requests


project = "networkx"
core = "core-developers"
emeritus = "emeritus-developers"
core_url = f"https://api.github.com/orgs/{project}/teams/{core}/members"
emeritus_url = f"https://api.github.com/orgs/{project}/teams/{emeritus}/members"


token = os.environ.get("GH_TOKEN", None)
if token is None:
    print(
        "No token found.  Please export a GH_TOKEN with permissions "
        "to read team members."
    )
    sys.exit(-1)


def api(url):
    json = requests.get(url=url, headers={"Authorization": f"token {token}"}).json()
    if "message" in json and json["message"] == "Bad credentials":
        raise RuntimeError("Invalid token provided")
    else:
        return json


resp = api(core_url)
core = sorted(resp, key=lambda user: user["login"].lower())

resp = api(emeritus_url)
emeritus = sorted(resp, key=lambda user: user["login"].lower())


def render_team(team):
    for member in team:
        profile = api(member["url"])

        print(
            f"""
.. raw:: html

   <div class="team-member">
     <a href="https://github.com/{member['login']}" class="team-member-name">
        <div class="team-member-photo">
           <img
             src="{member['avatar_url']}&s=40"
             loading="lazy"
             alt="Avatar picture of @{profile['login']}"
           />
        </div>
        {profile['name'] if profile['name'] else '@' + profile['login']}
     </a>
     <div class="team-member-handle">@{member['login']}</div>
   </div>
"""
        )


print(
    """
Core Developers
---------------

NetworkX development is guided by the following core team:

"""
)

render_team(core)

print(
    """

Emeritus Developers
-------------------

We thank these previously-active core developers for their contributions to NetworkX.

"""
)

render_team(emeritus)