#!/usr/bin/env python3 """ Script to update a manual in one language for one release Usage: python3 update_manual.py where: * manual_name can be 'mcc' or 'installer' * release can be 2 (installer only), 3, 4 or newer version * language is the language abreviation in lower case (en, fr, de, uk, tr...) * archive is the full path and name of the archive containing the new version of the manual (keep this file out of the git local repository) .. note:: Attention You need to have a clean and uptodate git local repository to use that script or it will try to 'git rm' files that are not under version control!! """ import sys from os import walk, makedirs from os.path import splitext, join, isdir from shutil import rmtree, move from zipfile import ZipFile from subprocess import call import fileinput import time def fix_image_path(path_to_fix, images_path): # 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('cco:/', images_path) # with fileinput, you need to use 'print' and not 'write' to # write in the file print(line) def fix_common_path(path_to_fix): # 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/') line = line.replace('
Uploaded on ' + time.strftime("%d/%m/%Y", time.gmtime()) + '