summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJarrod Millman <jarrod.millman@gmail.com>2020-07-30 16:59:26 -0700
committerGitHub <noreply@github.com>2020-07-30 16:59:26 -0700
commit887515c68b0b2377950b3a8149b15381faac9a7a (patch)
tree1adc7a7bee9af0929944c17839cce270bc1465c3 /tools
parent7f0a9755e1bf5345c515430ccbb66c205ef736ba (diff)
downloadnetworkx-887515c68b0b2377950b3a8149b15381faac9a7a.tar.gz
Add team gallery (#4117)
* Add team gallery * Update team generation tool - Handle case where full user name is empty - Make image and name clickable - Add alt tag to image - Add lazy load attribute to image * Catch bad token in team loader Co-authored-by: Stefan van der Walt <stefanv@berkeley.edu>
Diffstat (limited to 'tools')
-rw-r--r--tools/team_list.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/tools/team_list.py b/tools/team_list.py
new file mode 100644
index 00000000..ce2c2716
--- /dev/null
+++ b/tools/team_list.py
@@ -0,0 +1,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)