From 3d16ea3ade84c9940269ece9f5321b46059d60ca Mon Sep 17 00:00:00 2001 From: Muthu Subramanian Date: Wed, 24 Nov 2010 23:03:22 +0530 Subject: Combined convall.py with wikiconv2.py. --- helpcontent2/help-to-wiki.py | 2 +- helpcontent2/to-wiki/convall.py | 37 ------------------------------ helpcontent2/to-wiki/wikiconv2.py | 48 +++++++++++++++++++++------------------ 3 files changed, 27 insertions(+), 60 deletions(-) delete mode 100755 helpcontent2/to-wiki/convall.py diff --git a/helpcontent2/help-to-wiki.py b/helpcontent2/help-to-wiki.py index 446e02aacf..b77f1fe469 100755 --- a/helpcontent2/help-to-wiki.py +++ b/helpcontent2/help-to-wiki.py @@ -73,7 +73,7 @@ print "Generating the wiki itself..." localization = "" if len(sys.argv) > 1: localization = sys.argv[1] -os.system( "python to-wiki/convall.py "+localization ) +os.system( "python to-wiki/wikiconv2.py "+localization ) # close the bookmarks.h template create_wiki_footer() diff --git a/helpcontent2/to-wiki/convall.py b/helpcontent2/to-wiki/convall.py deleted file mode 100755 index 9ee46514f4..0000000000 --- a/helpcontent2/to-wiki/convall.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python - -import os, sys - -titles = [[]] -localization = "" - -def loadallfiles(filename): - global titles - file=open(filename,"r") - for line in file: - title = line.split(";", 2) - titles.append(title) - -loadallfiles("alltitles.csv") -if len(sys.argv) > 1: - localization = sys.argv[1] - -for title in titles: - command = "" - outfile = "" - infile = "" - if len(title) > 1: - outfile = "wiki/"+title[1].strip() - infile = title[0].strip() - command = "python to-wiki/wikiconv2.py "+infile+" "+title[1].strip()+" "+localization+" > "+outfile - - try: - file = open(outfile,"r") - except: - if os.system(command) != 0: - print "Failed: "+command - sys.exit(1) - continue - print "Warning: Skipping: "+command - file.close() - sys.exit(1) diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py index e6fe03f339..a3581fb247 100755 --- a/helpcontent2/to-wiki/wikiconv2.py +++ b/helpcontent2/to-wiki/wikiconv2.py @@ -6,7 +6,7 @@ import codecs root="source/" -titles = [] +titles = [[]] localization_data = [[]] @@ -1050,29 +1050,33 @@ def signal_handler(signal, frame): sys.exit(1) signal.signal(signal.SIGINT, signal_handler) -if len(sys.argv) < 2: - print "wikiconv2.py [Help Filename] [localize.sdf]" - sys.exit(1) - -if len(sys.argv) > 2: - help_file_name = sys.argv[2] +def wikiconv2(inputfile, help_filename, outputfile): + global help_file_name + help_file_name = help_filename + parser = XhpParser(inputfile, True, '') + file = codecs.open(outputfile, "wb", "utf-8") + file.write(parser.get_all()) + file.close() + Bookmark.save_bookmarks() -if len(sys.argv) > 3: - load_localization_data(sys.argv[3]) - -# TODO: Currently the following files are loaded for every -# file which is converted. Combine the batch converter with -# this file to generate quicker help files. +# Main Function load_all_help_ids() loadallfiles("alltitles.csv") - -parser = XhpParser(sys.argv[1], True, '') -# Enable these lines once the convall.py is combined with this one -#file1 = codecs.open("t.txt", "wb", "utf-8") -#file1.write(parser.get_all()) -#file1.close() -print parser.get_all().encode('utf-8') - -Bookmark.save_bookmarks() +if len(sys.argv) > 1: + load_localization_data(sys.argv[1]) + +for title in titles: + outfile = "" + infile = "" + if len(title) > 1: + outfile = "wiki/"+title[1].strip() + infile = title[0].strip() + try: + file = open(outfile,"r") + except: + wikiconv2(infile,title[1].strip(),outfile) + continue + print "Warning: Skipping: "+infile+" > "+outfile + file.close() # vim:set shiftwidth=4 softtabstop=4 expandtab: -- cgit