From 71487660812754e5f26f26595b6c3d456f9f6db8 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 8 Oct 2021 00:30:08 -0400 Subject: Get rid of conversion stuff, just build content -> website --- kludge-camelcase-oopsies.py | 54 --------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100755 kludge-camelcase-oopsies.py (limited to 'kludge-camelcase-oopsies.py') diff --git a/kludge-camelcase-oopsies.py b/kludge-camelcase-oopsies.py deleted file mode 100755 index ab5658d..0000000 --- a/kludge-camelcase-oopsies.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -# -# Kludges specific to converting the Cryptech wiki - -import os, re - -brute_force = ( - ("{filename}DNSSEC/Requirements", "{filename}DNSSEC-Requirements"), - ("[OpenDNSSEC](OpenDNSSEC)", "[OpenDNSSEC]({filename}OpenDNSSEC.md)"), - ("[PKCS11Proxy](PKCS11Proxy)", "[PKCS11Proxy]({filename}PKCS11Proxy.md)"), - ('[Collection about side-channel attacks and detection, mitigation methods"]({filename}SideChannel".md)', - '[Collection about side-channel attacks and detection, mitigation methods]({filename}SideChannel.md)'), - ("[Joachim Strömbergson](Joachim Strömbergson)", "[Joachim Strömbergson]({filename}Joachim Strömbergson.md)"), - ('EDAToolchainSurvey"', 'EDAToolchainSurvey'), - ("[for Tor?](1024)", "\[ 1024 for Tor? \]"), - ("[done, nothing using it yet](Mechanism)", "\[Mechanism done, nothing using it yet\]"), - ("[but waiting on a BSD-friendly license](Done,)", "\[Done, but waiting on a BSD-friendly license\]"), - ("[done](Mechanism)", "\[Mechanism done\]"), - ("[Done]", "\[Done\]"), - ("[done]", "\[done\]"), -) - -camel_regexp = re.compile(r"\[(.+?)\]\((?:{filename})?\1.md\)") -foot_regexp = re.compile(r"\[\(([0-9]+)\)\]\(=#fn[0-9]+\)") - -def camel_replacer(dn, m): - if os.path.exists(os.path.join(dn, m.group(1) + ".md")): - return m.group(0) - else: - return m.group(1) - -for root, dirs, files in os.walk("pelican/content"): - for fn in files: - if not fn.endswith(".md"): - continue - fn = os.path.join(root, fn) - dn = os.path.dirname(fn) - with open(fn) as f: - lines = f.readlines() - changes = False - for i, line in enumerate(lines): - for old, new in brute_force: - line = line.replace(old, new) - line = foot_regexp.sub(r"\1.", line) - line = camel_regexp.sub(lambda m: camel_replacer(dn, m), line) - if line != lines[i]: - changes = True - lines[i] = line - if changes: - tn = fn + ".tmp" - with open(tn, "w") as f: - for line in lines: - f.write(line) - os.rename(tn, fn) -- cgit v1.2.3