From 31de6bec62a0eb30062cf14b010c44c70486621a Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Mon, 6 Dec 2010 21:33:09 +0100 Subject: wikihelp: wikiconv2 into a module. Don't generate redirects by default. --- helpcontent2/help-to-wiki.py | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'helpcontent2/help-to-wiki.py') diff --git a/helpcontent2/help-to-wiki.py b/helpcontent2/help-to-wiki.py index 9af54e59f3..05a5a074e5 100755 --- a/helpcontent2/help-to-wiki.py +++ b/helpcontent2/help-to-wiki.py @@ -1,10 +1,23 @@ #!/usr/bin/env python -import sys, os +import sys, os, getopt + +sys.path.append(sys.path[0]+"/to-wiki") +import wikiconv2 # FIXME do proper modules from getalltitles & wikiconv2 # [so far this is in fact just a shell thing] +def usage(): + print ''' +help-to-wiki.py - converts .xhp files into a wiki + +-h, --help - this help +-r, --redirects - generate also redirect pages + +Most probably, you want to generate the redirects only once when you initially +populate the wiki, and then only update the ones that broke.\n''' + def create_wiki_dirs(): dirs = [ "Common", @@ -37,16 +50,27 @@ def create_wiki_dirs(): except: pass -# do the work +# Argument handling +try: + opts, args = getopt.getopt(sys.argv[1:], 'hr', ['help', 'redirects']) +except getopt.GetoptError: + usage() + sys.exit(1) + +generate_redirects = False +for opt, arg in opts: + if opt in ('-h', '--help'): + usage() + sys.exit() + elif opt in ('-r', '--redirects'): + generate_redirects = True + +# Do the work create_wiki_dirs() print "Generating the titles..." os.system( "python to-wiki/getalltitles.py source/text > alltitles.csv" ) -print "Generating the wiki itself..." -localization = "" -if len(sys.argv) > 1: - localization = sys.argv[1] -os.system( "python to-wiki/wikiconv2.py "+localization ) +wikiconv2.convert(generate_redirects, args) # vim:set shiftwidth=4 softtabstop=4 expandtab: -- cgit