From 92996bed8f29772f4eeb507f3f8522816e58a884 Mon Sep 17 00:00:00 2001 From: Claire Revillet Date: Mon, 11 May 2015 22:33:33 +0200 Subject: add a fix for missing images in update script --- update_manual.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'update_manual.py') diff --git a/update_manual.py b/update_manual.py index ab1c4939..e664a238 100644 --- a/update_manual.py +++ b/update_manual.py @@ -27,6 +27,22 @@ import fileinput +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 us '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): @@ -71,6 +87,9 @@ if __name__ == "__main__": # create the path to the manual manual_path = join(manual_name, release, language) + # create the path of the EN manual for missing images + image_path = "../../en/content/images/" + # create the zip interface archive_int = ZipFile(archive) @@ -94,6 +113,9 @@ if __name__ == "__main__": # ... fix the links fix_common_path(manual_path) + # fix the links for missing images + fix_image_path(manual_path, image_path) + # tell git about the changes command_add = ['git', 'add'] + files_to_add call(command_add) -- cgit v1.2.1