aboutsummaryrefslogtreecommitdiff
path: root/kludge-camelcase-oopsies.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2021-10-08 00:30:08 -0400
committerRob Austein <sra@hactrn.net>2021-10-08 00:30:08 -0400
commit71487660812754e5f26f26595b6c3d456f9f6db8 (patch)
treee960190262edcbb0164edbac1e52915c5a339442 /kludge-camelcase-oopsies.py
parentb11298b250f63daf091591d1638608325f766d9a (diff)
Get rid of conversion stuff, just build content -> website
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)