diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..119062d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/__pycache__/ +certs/ diff --git a/generate.py b/generate.py new file mode 100644 index 0000000..c99440d --- /dev/null +++ b/generate.py @@ -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() diff --git a/template.html b/template.html index af07b48..9596b98 100644 --- a/template.html +++ b/template.html @@ -1,238 +1,238 @@ -
- -