aboutsummaryrefslogtreecommitdiffstats
path: root/fix_common_path.py
diff options
context:
space:
mode:
Diffstat (limited to 'fix_common_path.py')
-rw-r--r--fix_common_path.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/fix_common_path.py b/fix_common_path.py
new file mode 100644
index 00000000..20d974c4
--- /dev/null
+++ b/fix_common_path.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+""" Script to fix the path to the common files in Mageia html documentation
+
+ Usage: python3 fix_common_path.py
+
+"""
+from os import walk
+from os.path import splitext, join
+import fileinput
+
+path_to_fix = 'mcc/4/tr'
+
+# first step: let's walk along the folder
+for root, dirs, files in walk(path_to_fix):
+ # second step: identification of html files
+ for elem in files:
+ if splitext(elem)[1] == '.html':
+ # third step: replacing the path
+ with fileinput.input(files=join(root, elem), inplace=True) as f:
+ for line in f:
+ line = line.rstrip('\n')
+ line = line.replace('"../common/', '"../../common/')
+ line = line.replace('(../common/', '(../../common/')
+ # with fileinput, you need to us 'print' and not 'write' to
+ # write in the file
+ print(line)