aboutsummaryrefslogtreecommitdiff
path: root/kludge-cgit-urls.py
diff options
context:
space:
mode:
Diffstat (limited to 'kludge-cgit-urls.py')
-rwxr-xr-xkludge-cgit-urls.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/kludge-cgit-urls.py b/kludge-cgit-urls.py
index 9d9feed..4867fed 100755
--- a/kludge-cgit-urls.py
+++ b/kludge-cgit-urls.py
@@ -9,6 +9,8 @@ with open("repositories.json") as f:
plain = "](https://git.cryptech.is"
export = "](export:/"
+browser = "https://trac.cryptech.is/browser/"
+gitrepositories = "GitRepositories/"
regexp = re.compile(r"(\(https://git\.cryptech\.is/(?:" + repo_or + "))([(/)])")
for root, dirs, files in os.walk("pelican/content"):
@@ -18,11 +20,21 @@ for root, dirs, files in os.walk("pelican/content"):
fn = os.path.join(root, fn)
with open(fn) as f:
lines = f.readlines()
- if not any(plain in line or export in line for line in lines):
+ if not any(any(pattern in line for pattern in (plain, export, browser, gitrepositories))
+ for line in lines):
continue
changes = 0
for i, line in enumerate(lines):
- if export in line:
+ if browser in line:
+ changes = 1
+ line = line.replace(browser, "https://git.cryptech.is/")
+ elif gitrepositories in line:
+ changes = 1
+ line = line \
+ .replace("[GitRepositories/", "[") \
+ .replace("(GitRepositories/", "(https://git.cryptech.is/") \
+ .replace("({filename}GitRepositories/", "(https://git.cryptech.is/")
+ elif export in line:
changes = 1
line = line.replace(export, "](https://git.cryptech.is/")
elif plain not in line: