aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autodownload.py8
-rw-r--r--update_manual.py133
2 files changed, 79 insertions, 62 deletions
diff --git a/autodownload.py b/autodownload.py
index 24108656..11ba0cad 100644
--- a/autodownload.py
+++ b/autodownload.py
@@ -23,13 +23,13 @@ from html.parser import HTMLParser
manual_name_prefix = {"installer": "DrakX-",
- "MCC": "MCC-"}
+ "MCC": "MCC-", "draklive": "DrakLive-"}
manual_name_suffix = "WebHelp-zipped.zip"
def usage():
print("python3 autodownlaod.py <manual> [<server_url>]")
- print("\t <manual>: MCC or installer")
+ print("\t <manual>: MCC, installer or draklive")
print("\t <server_url>: (optional) if not given: " +
"http://docteam.mageia.nl/zipped/ will be used")
@@ -82,8 +82,8 @@ if __name__ == "__main__":
if len(sys.argv) == 3:
base_url = sys.argv[2]
else:
- base_url = "http://docteam.mageia.nl/zipped/"
- base_url = base_url + "/" + manual + "/"
+ base_url = "http://docteam.mageia.nl/zipped"
+ base_url = base_url + "/" + manual
print(base_url)
language_list = getPage(base_url)
for elem in language_list:
diff --git a/update_manual.py b/update_manual.py
index 8c21b1b4..484c2012 100644
--- a/update_manual.py
+++ b/update_manual.py
@@ -57,6 +57,8 @@ def fix_common_path(path_to_fix):
line = line.replace('(../common/', '(../../common/')
line = line.replace('</a></div><div class="navfooter">',
'</a></div><div id="upload_date">Uploaded on ' + time.strftime("%d/%m/%Y", time.gmtime()) + '</div><div class="navfooter">')
+ line = line.replace('http://docteam.mageia.nl/favicon.png','https://www.mageia.org/g/favicon.png')
+ line = line.replace('http://docteam.mageia.nl/mageia-2013-200p.png','https://doc.mageia.org/g/mageia-2013-200p.png')
# with fileinput, you need to use 'print' and not 'write' to
# write in the file
print(line)
@@ -77,71 +79,86 @@ def check_changes_in_filelist(path_to_check, archive_list):
if __name__ == "__main__":
- if len(sys.argv) != 5:
+ if len(sys.argv) < 4:
print("Usage: python3 update_manual.py <manual_name> " +
- "<release> <language> <archive>")
+ "<release> <archive_base> [<language>]\n{} arguments given".format(len(sys.argv)))
else:
manual_name = sys.argv[1]
release = sys.argv[2]
- language = sys.argv[3]
- archive = sys.argv[4]
-
- # create the path to the manual
- manual_path = join(manual_name, release, language)
- if not isdir(manual_path):
- makedirs(manual_path)
- print("Processing manual " + 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/"
-
- # create the zip interface
- archive_int = ZipFile(archive)
-
- # check for changes
- files_to_add, files_to_remove = \
- check_changes_in_filelist(manual_path, archive_int.namelist())
-
- # unzip the archive
- archive_int.extractall(manual_path)
-
- 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)
+ if len(sys.argv) == 5:
+ languages = sys.argv[4]
else:
- # or remove the common directory and ...
- rmtree(common_dir)
+ # define languages lists. en must be first
+ languages = { 'installer':'en cs de el eo es et eu fr hr id it nl pl pt_br ro ru sk sl sq sv tr uk zh_CN',
+ 'mcc':'en ca cs de el es et eu fr id t nl pl pt_br ro ru sk sl sv tr uk',
+ 'draklive':'en cs de el es et eu fr hr nl ro sk sl sv uk zh_CN'}
+ archive_base = sys.argv[3]
+
+ # define manuals base name
+ root_name = {'mcc' : 'MCC', 'installer': 'DrakX', 'draklive': 'DrakLive'}
+ for language in languages[manual_name].split(' '):
+ # create the path to the manual
+ manual_path = join(manual_name, release, language)
+ if not isdir(manual_path):
+ makedirs(manual_path)
+ print("Processing {} manual in {}".format(manual_name,language))
+
+ # 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/"
+
+ # create the zip interface
+ archive = '{ab}/{manual}-{lang}-WebHelp-zipped.zip'.format(ab=archive_base,manual=root_name[manual_name], lang=language.upper())
+ try :
+ archive_int = ZipFile(archive)
+ except:
+ print('{} not found'.format(archive))
+ continue
+
+ # check for changes
+ files_to_add, files_to_remove = \
+ check_changes_in_filelist(manual_path, archive_int.namelist())
+
+ # unzip the archive
+ archive_int.extractall(manual_path)
+
+ 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)
+ # ... fix the links
+ fix_common_path(manual_path)
- # fix the links for missing images
- fix_image_path(manual_path, image_path)
+ # fix the links for missing images
+ fix_image_path(manual_path, image_path)
- # tell git about the changes
- if len(files_to_add) == 0:
- print("Nothing to add to the git")
- else:
- command_add = ['git', 'add'] + files_to_add
- call(command_add)
+ # tell git about the changes
+ if len(files_to_add) == 0:
+ print("Nothing to add to the git")
+ else:
+ command_add = ['git', 'add'] + files_to_add
+ call(command_add)
- if len(files_to_remove) == 0:
- print("Nothing to remove from the git")
- else:
- command_remove = ['git', 'rm'] + files_to_remove
- call(command_remove)
+ if len(files_to_remove) == 0:
+ print("Nothing to remove from the git")
+ else:
+ command_remove = ['git', 'rm'] + files_to_remove
+ call(command_remove)
- # ask for git status (the user has to commit himself)
- command_status = ['git', 'status']
- call(command_status)
+ # committing
+ command_commit = ['git', 'commit', '-m Adding or refreshing {} in {}'.format(manual_name,language),
+ '{}/{}/{}/*'.format(manual_name,release,language)]
+ call(command_commit)