diff options
author | Muthu Subramanian <sumuthu@novell.com> | 2010-11-24 23:03:22 +0530 |
---|---|---|
committer | Muthu Subramanian <sumuthu@novell.com> | 2010-11-24 23:03:22 +0530 |
commit | 3d16ea3ade84c9940269ece9f5321b46059d60ca (patch) | |
tree | 4749e80b468333277244e4465fd835e61786109b /helpcontent2/to-wiki | |
parent | 9888e8e16502f34ac4371d7edfcf13a67e1a73de (diff) |
Combined convall.py with wikiconv2.py.
Diffstat (limited to 'helpcontent2/to-wiki')
-rwxr-xr-x | helpcontent2/to-wiki/convall.py | 37 | ||||
-rwxr-xr-x | helpcontent2/to-wiki/wikiconv2.py | 48 |
2 files changed, 26 insertions, 59 deletions
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 <inputfile.xph> [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: |