Add python script to do repetitive code changes.
authorCarl Hetherington <cth@carlh.net>
Sun, 4 Oct 2020 21:31:47 +0000 (23:31 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 13 Oct 2020 16:51:11 +0000 (18:51 +0200)
hacks/fix.py [new file with mode: 0644]

diff --git a/hacks/fix.py b/hacks/fix.py
new file mode 100644 (file)
index 0000000..b7ba73f
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/python3
+
+import os
+import re
+import sys
+
+filename = sys.argv[1]
+
+o = open(filename + '.tmp', 'w')
+
+for l in open(sys.argv[1]).readlines():
+    if l.find("test/data") != -1 or l.find("build/test") != -1:
+        m = re.match('.*("[^"]*")', l)
+        try:
+            path = m.group(1)
+            bits = path[1:-1].split('/')
+            fixed = 'path("%s")' % bits[0]
+            for b in bits[1:]:
+                fixed += ' / "%s"' % b
+            l = l.replace(path, fixed)
+        except:
+            pass
+    print(l, end='', file=o)
+
+os.rename(filename + '.tmp', filename)
+
+