httpie-cli/docs/contributors/generate.py
Mickaël Schoentgen a65771e271
Add a script that lists all contributors to a release (#1181)
* Add a script that lists all contributors to a release

We will keep a contributors database (simple JSON file) where
each entry is a contributor (either a committer, either an issue reporter,
either both) with some nicknames (GitHub, and Twitter).
The file will be used to craft credits on our release blog posts and to ping
them on Twitter.

* Add templates

* Missing docstring

* Clean-up

* Tweak
2021-10-14 10:33:14 +02:00

42 lines
989 B
Python

"""
Generate snippets to copy-paste.
"""
import sys
from jinja2 import Template
from fetch import HERE, load_awesome_people
TPL_FILE = HERE / 'snippet.jinja2'
HTTPIE_TEAM = {'jakubroztocil', 'BoboTiG', 'claudiatd'}
def generate_snippets(release: str) -> str:
people = load_awesome_people()
contributors = {
name: details
for name, details in people.items()
if details['github'] not in HTTPIE_TEAM
and (release in details['committed'] or release in details['reported'])
}
template = Template(source=TPL_FILE.read_text(encoding='utf-8'))
output = template.render(contributors=contributors, release=release)
print(output)
return 0
if __name__ == '__main__':
ret = 1
try:
ret = generate_snippets(sys.argv[1])
except (IndexError, TypeError):
ret = 2
print(f'''
Generate snippets for contributors to a release.
Usage:
python {sys.argv[0]} {sys.argv[0]} <RELEASE>
''')
sys.exit(ret)