aboutsummaryrefslogtreecommitdiffstats
path: root/update_manual.py
diff options
context:
space:
mode:
authorgrenoya <grenoya@zarb.org>2015-05-13 16:43:01 +0200
committergrenoya <grenoya@zarb.org>2015-05-13 16:43:01 +0200
commit66cb288703fe6fe31a541dd788bcb2fc6b467dc2 (patch)
tree36e110771247ddf9c7af0a3b2f9d772fb9b0b6e0 /update_manual.py
parenta3521bab8491afadcd6f5d1c6fd2815f624b73d6 (diff)
downloaddoc-66cb288703fe6fe31a541dd788bcb2fc6b467dc2.tar
doc-66cb288703fe6fe31a541dd788bcb2fc6b467dc2.tar.gz
doc-66cb288703fe6fe31a541dd788bcb2fc6b467dc2.tar.bz2
doc-66cb288703fe6fe31a541dd788bcb2fc6b467dc2.tar.xz
doc-66cb288703fe6fe31a541dd788bcb2fc6b467dc2.zip
modify update_manual to allow upload of new manuals
Diffstat (limited to 'update_manual.py')
-rw-r--r--update_manual.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/update_manual.py b/update_manual.py
index e664a238..a9a56064 100644
--- a/update_manual.py
+++ b/update_manual.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
-""" Script to update a manual in one language for one release
+""" Script to update a manual in one language for one release
Usage: python3 update_manual.py <manual_name> <release> <language> <archive>
-
+
where:
* manual_name can be 'mcc' or 'installer'
@@ -10,7 +10,7 @@
* 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
@@ -18,15 +18,14 @@
"""
import sys
-from os import walk
-from os.path import splitext, join
+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
-
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):
@@ -61,7 +60,7 @@ def fix_common_path(path_to_fix):
def check_changes_in_filelist(path_to_check, archive_list):
- toadd = [join(path_to_check, elem) for elem in archive_list
+ toadd = [join(path_to_check, elem) for elem in archive_list
if not elem.startswith("common")]
toremove = []
for root, dirs, files in walk(path_to_check):
@@ -86,6 +85,16 @@ if __name__ == "__main__":
# create the path to the manual
manual_path = join(manual_name, release, language)
+ if not isdir(manual_path):
+ makedirs(manual_path)
+
+ # create path to common directories
+ common_dir = join(manual_path, 'common')
+ if not isdir(common_dir):
+ makedirs(common_dir)
+ common_common_path = join(manual_name, release, 'common')
+ if not isdir(common_common_path):
+ makedirs(common_common_path)
# create the path of the EN manual for missing images
image_path = "../../en/content/images/"
@@ -99,17 +108,17 @@ if __name__ == "__main__":
# unzip the archive
archive_int.extractall(manual_path)
- common_dir = join(manual_path, 'common')
- common_common_path = join(manual_name, release, 'common')
if language == "en":
# if english, copy the common directory in the manual/release path
rmtree(common_common_path)
move(common_dir, common_common_path)
+ # add common dir in case it's new
+ files_to_add.append(common_common_path)
else:
# or remove the common directory and ...
rmtree(common_dir)
-
+
# ... fix the links
fix_common_path(manual_path)
@@ -126,5 +135,3 @@ if __name__ == "__main__":
# ask for git status (the user has to commit himself)
command_status = ['git', 'status']
call(command_status)
-
-