File: generate_collaborators_gallery.py

package info (click to toggle)
pydata-sphinx-theme 0.16.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,088 kB
  • sloc: python: 2,796; javascript: 701; makefile: 42; sh: 12
file content (37 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download
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
"""
Uses the GitHub API to list a gallery of all people with direct access to the
repository.
"""

import json
import shlex

from pathlib import Path
from subprocess import run

from yaml import dump


COLLABORATORS_API = "https://api.github.com/repos/pydata/pydata-sphinx-theme/collaborators?affiliation=direct"

print("Grabbing latest collaborators with GitHub API via GitHub's CLI...")
out = run(shlex.split(f"gh api {COLLABORATORS_API}"), capture_output=True)
collaborators = json.loads(out.stdout.decode())
path_docs_source = Path(__file__).parent.parent
path_collaborators = path_docs_source / "_static/contributors.yaml"
contributor_yaml = []
for collaborator in collaborators:
    # contributor_yaml =
    contributor_yaml.append(
        {
            "header": f"@{collaborator['login']}",
            "image": f"https://avatars.githubusercontent.com/u/{collaborator['id']}",
            "link": collaborator["html_url"],
        }
    )

print("Writing collaborator YAML to disk...")
path_collaborators.touch()
with path_collaborators.open("w+") as ff:
    dump(contributor_yaml, ff)
print("Finished!")