Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/__pycache__/
certs/
32 changes: 32 additions & 0 deletions generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import json
from pathlib import Path

SHILLS_PATH = Path("shills.json")
TEMPLATE_PATH = Path("template.html")
CERTS_PATH = Path("certs")


def main() -> None:
entries: dict[str, str | list[str]] = json.loads(SHILLS_PATH.read_text())
template = TEMPLATE_PATH.read_text()
CERTS_PATH.mkdir(exist_ok=True)

for name, shillings in entries.items():
if isinstance(shillings, str):
# Person only shills one thing
shillings = [shillings]

for shilling in shillings:
create_certificate(name, shilling, template)


def create_certificate(name: str, shilling: str, template: str) -> None:
cert_html = template.replace("{name}", name).replace("{shilling}", shilling)
cert_path = CERTS_PATH / f"{name}_{shilling}.html"
cert_path.write_text(cert_html)

print(f"{name} ({shilling}) -> {cert_path}")


if __name__ == "__main__":
main()
Loading