Debian Codegraph @

docs/scripts/generate_collaborators_gallery.py

raw
1 """
2 Uses the GitHub API to list a gallery of all people with direct access to the
3 repository.
4 """
5
6 import json
7 import shlex
8
9 from pathlib import Path
10 from subprocess import run
11
12 from yaml import dump
13
14
15 COLLABORATORS_API = "https://api.github.com/repos/pydata/pydata-sphinx-theme/collaborators?affiliation=direct"
16
17 print("Grabbing latest collaborators with GitHub API via GitHub's CLI...")
18 out = run(shlex.split(f"gh api {COLLABORATORS_API}"), capture_output=True)
19 collaborators = json.loads(out.stdout.decode())
20 path_docs_source = Path(__file__).parent.parent
21 path_collaborators = path_docs_source / "_static/contributors.yaml"
22 contributor_yaml = []
23 for collaborator in collaborators:
24 # contributor_yaml =
25 contributor_yaml.append(
26 {
27 "header": f"@{collaborator['login']}",
28 "image": f"https://avatars.githubusercontent.com/u/{collaborator['id']}",
29 "link": collaborator["html_url"],
30 }
31 )
32
33 print("Writing collaborator YAML to disk...")
34 path_collaborators.touch()
35 with path_collaborators.open("w+") as ff:
36 dump(contributor_yaml, ff)
37 print("Finished!")