aboutsummaryrefslogtreecommitdiff
path: root/kludges.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2021-07-11 21:14:59 +0000
committerRob Austein <sra@hactrn.net>2021-07-11 21:14:59 +0000
commitd85a1e4e2eaa340dc83938bfda33bf2a9e7f50f6 (patch)
tree151fc40e5cffd55a95a467d66c10b47a9067ca75 /kludges.py
parentbfebab9957c63d460874d3ec8f6100f9b49de080 (diff)
More git link cleanup
* Fix Trac "export:" links * Use "about" link for naked repository links so default view is the README.md * Adjust to match new cgit configuration which hides ".git" suffixes
Diffstat (limited to 'kludges.py')
-rwxr-xr-xkludges.py36
1 files changed, 0 insertions, 36 deletions
diff --git a/kludges.py b/kludges.py
deleted file mode 100755
index c0de7e1..0000000
--- a/kludges.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python3
-#
-# Kludges specific to converting the Cryptech wiki
-
-import os, re, json
-
-with open("repositories.json") as f:
- repo_or = "|".join(os.path.splitext(r)[0] for r in json.load(f))
-
-plain = "](https://git.cryptech.is"
-
-regexp = re.compile(r"(\(https://git\.cryptech\.is/(?:" + repo_or + "))([(/)])")
-
-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)
- with open(fn) as f:
- lines = f.readlines()
- if not any(plain in line for line in lines):
- continue
- changes = 0
- for i, line in enumerate(lines):
- if plain not in line:
- continue
- lines[i], n = regexp.subn(
- lambda m: m.group(1) + (".git/tree" if m.group(2) == "/" else ".git") + m.group(2),
- line)
- changes += n
- if changes:
- tn = fn + ".tmp"
- with open(tn, "w") as f:
- for line in lines:
- f.write(line)
- os.rename(tn, fn)