From bb508b3f4b2d0b2586c22a7e8957988653b60f8d Mon Sep 17 00:00:00 2001 From: interrrp Date: Sat, 6 Jan 2024 19:38:35 +0800 Subject: [PATCH 1/6] Create a certificate generation script --- certs/interrrp.html | 238 ++++++++++++++++++++++++++ certs/sexnine.html | 238 ++++++++++++++++++++++++++ generate.py | 46 +++++ template.html | 408 ++++++++++++++++++++++---------------------- 4 files changed, 726 insertions(+), 204 deletions(-) create mode 100644 certs/interrrp.html create mode 100644 certs/sexnine.html create mode 100644 generate.py diff --git a/certs/interrrp.html b/certs/interrrp.html new file mode 100644 index 0000000..28c11e4 --- /dev/null +++ b/certs/interrrp.html @@ -0,0 +1,238 @@ + + + + + interrrp shills Microsoft + + + +
+
+
+ +
+
+
+

Let's Build A... Certificate of Shillfulness

+
+
+ +
+
+
+
+
+
+ interrrp +
+
+
+
+ +
+
+
+
+ has became a + Microsoft Shill +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + diff --git a/certs/sexnine.html b/certs/sexnine.html new file mode 100644 index 0000000..263998c --- /dev/null +++ b/certs/sexnine.html @@ -0,0 +1,238 @@ + + + + + sexnine shills Cloudflare + + + +
+
+
+ +
+
+
+

Let's Build A... Certificate of Shillfulness

+
+
+ +
+
+
+
+
+
+ sexnine +
+
+
+
+ +
+
+
+
+ has became a + Cloudflare Shill +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + diff --git a/generate.py b/generate.py new file mode 100644 index 0000000..39e6101 --- /dev/null +++ b/generate.py @@ -0,0 +1,46 @@ +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, shilling in entries.items(): + 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: + """Format a list of items as a comma-separated list with an "and" before the last item. + + >>> format_csv_with_and(["a", "b", "c"]) + 'a, b, and c' + >>> format_csv_with_and(["a", "b"]) + 'a and b' + """ + + if len(items) == 1: + return items[0] + elif len(items) == 2: + return f"{items[0]} and {items[1]}" + else: + return ", ".join(items[:-1]) + f", and {items[-1]}" + + +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 @@ - - - Title + + + {name} shills {shilling} - - -
-
-
+ + +
+
+
-
+
-
-

Let's Build A... Certificate of Shillfullness

-
+
+

Let's Build A... Certificate of Shillfulness

+
-
-
-
-
-
- Anonymous4045 -
-
-
+
+
+
+
+
+ {name}
+
+
+
-
-
-
-
- has became a - Linux Shill -
-
-
-
+
+
+
+
+ has became a + {shilling} Shill
+
+
+
+
-
-
- -
+
+
+ +
+
+
-
- - \ No newline at end of file + + From 2d67860fea477db9179fa7e7b7da2d8589618170 Mon Sep 17 00:00:00 2001 From: interrrp Date: Sat, 6 Jan 2024 19:53:26 +0800 Subject: [PATCH 2/6] Move certificate generation into its own function --- generate.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/generate.py b/generate.py index 39e6101..6a90ce8 100644 --- a/generate.py +++ b/generate.py @@ -12,27 +12,25 @@ 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: - """Format a list of items as a comma-separated list with an "and" before the last item. - >>> format_csv_with_and(["a", "b", "c"]) - 'a, b, and c' - >>> format_csv_with_and(["a", "b"]) - 'a and b' - """ +def format_csv_with_and(items: list[str]) -> str: + """Format a list of items as a comma-separated list with an "and" before the last item.""" if len(items) == 1: return items[0] From 0bc18a4296a90b9e7e89033e6c06fb5ab3be34a9 Mon Sep 17 00:00:00 2001 From: interrrp Date: Sun, 7 Jan 2024 07:27:00 +0800 Subject: [PATCH 3/6] Generate one certificate for each shilling --- certs/interrrp.html | 238 -------------------------------------------- certs/sexnine.html | 238 -------------------------------------------- generate.py | 30 ++---- 3 files changed, 9 insertions(+), 497 deletions(-) delete mode 100644 certs/interrrp.html delete mode 100644 certs/sexnine.html diff --git a/certs/interrrp.html b/certs/interrrp.html deleted file mode 100644 index 28c11e4..0000000 --- a/certs/interrrp.html +++ /dev/null @@ -1,238 +0,0 @@ - - - - - interrrp shills Microsoft - - - -
-
-
- -
-
-
-

Let's Build A... Certificate of Shillfulness

-
-
- -
-
-
-
-
-
- interrrp -
-
-
-
- -
-
-
-
- has became a - Microsoft Shill -
-
-
-
-
- -
-
- -
-
-
-
-
-
- - diff --git a/certs/sexnine.html b/certs/sexnine.html deleted file mode 100644 index 263998c..0000000 --- a/certs/sexnine.html +++ /dev/null @@ -1,238 +0,0 @@ - - - - - sexnine shills Cloudflare - - - -
-
-
- -
-
-
-

Let's Build A... Certificate of Shillfulness

-
-
- -
-
-
-
-
-
- sexnine -
-
-
-
- -
-
-
-
- has became a - Cloudflare Shill -
-
-
-
-
- -
-
- -
-
-
-
-
-
- - diff --git a/generate.py b/generate.py index 6a90ce8..22261ee 100644 --- a/generate.py +++ b/generate.py @@ -11,34 +11,22 @@ def main() -> None: template = TEMPLATE_PATH.read_text() CERTS_PATH.mkdir(exist_ok=True) - for name, shilling in entries.items(): - create_certificate(name, shilling, template) + 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 | 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" +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} -> {cert_path}") -def format_csv_with_and(items: list[str]) -> str: - """Format a list of items as a comma-separated list with an "and" before the last item.""" - - if len(items) == 1: - return items[0] - elif len(items) == 2: - return f"{items[0]} and {items[1]}" - else: - return ", ".join(items[:-1]) + f", and {items[-1]}" - - if __name__ == "__main__": main() From e544f457653bc14e33260ab3d295acbdd3ad0016 Mon Sep 17 00:00:00 2001 From: interrrp Date: Sun, 7 Jan 2024 07:29:03 +0800 Subject: [PATCH 4/6] Improve generation script output --- generate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generate.py b/generate.py index 22261ee..bc4db8f 100644 --- a/generate.py +++ b/generate.py @@ -22,10 +22,10 @@ def main() -> None: 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 = CERTS_PATH / f"{name}_{shilling}.html" cert_path.write_text(cert_html) - print(f"{name} -> {cert_path}") + print(f"Generated {shilling} certificate for {name} at {cert_path}") if __name__ == "__main__": From ae36f284e72a92ac9dfa0b5dbba2aee773cff662 Mon Sep 17 00:00:00 2001 From: interrrp Date: Sun, 7 Jan 2024 07:30:32 +0800 Subject: [PATCH 5/6] Simplify generation logging --- generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate.py b/generate.py index bc4db8f..c99440d 100644 --- a/generate.py +++ b/generate.py @@ -25,7 +25,7 @@ def create_certificate(name: str, shilling: str, template: str) -> None: cert_path = CERTS_PATH / f"{name}_{shilling}.html" cert_path.write_text(cert_html) - print(f"Generated {shilling} certificate for {name} at {cert_path}") + print(f"{name} ({shilling}) -> {cert_path}") if __name__ == "__main__": From 253eee181cc40d87d59ddb713cb2fcc965f5d002 Mon Sep 17 00:00:00 2001 From: interrrp Date: Sun, 7 Jan 2024 07:32:37 +0800 Subject: [PATCH 6/6] Add pycache and cert files to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..119062d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/__pycache__/ +certs/