From 1f5096e898cf6aea1a385e5a7dfc71c29a639e7b Mon Sep 17 00:00:00 2001 From: Claire Revillet Date: Wed, 8 Apr 2015 21:21:29 +0200 Subject: add script to use a unique common folder for all lang. of a doc --- fix_common_path.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 fix_common_path.py 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) -- cgit v1.2.1