Skip to content

Commit

Permalink
Move certificate generation into its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
interrrp committed Jan 6, 2024
1 parent bb508b3 commit 6708953
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ def main() -> None:
CERTS_PATH.mkdir(exist_ok=True)

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

cert_html = template.replace("{name}", name).replace(
"{shilling}", format_csv_with_and(shilling)
)
cert_path = CERTS_PATH / f"{name}.html"
cert_path.write_text(cert_html)

print(f"{name} -> {cert_path}")
def create_certificate(name: str, shilling: str | list[str], template: str) -> None:
if isinstance(shilling, str):
# Person only shills one thing
shilling = [shilling]

cert_html = template.replace("{name}", name).replace(
"{shilling}", format_csv_with_and(shilling)
)
cert_path = CERTS_PATH / f"{name}.html"
cert_path.write_text(cert_html)

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


def format_csv_with_and(items: list[str]) -> str:
Expand Down

0 comments on commit 6708953

Please sign in to comment.