aboutsummaryrefslogtreecommitdiff
path: root/kludge-camelcase-oopsies.py
diff options
context:
space:
mode:
Diffstat (limited to 'kludge-camelcase-oopsies.py')
-rwxr-xr-xkludge-camelcase-oopsies.py54
1 files changed, 0 insertions, 54 deletions
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)