summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2010-12-06 21:33:09 +0100
committerJan Holesovsky <kendy@suse.cz>2010-12-06 21:33:09 +0100
commit31de6bec62a0eb30062cf14b010c44c70486621a (patch)
treea6ae9c7c312389f8e311116b0c87893de8ad0e29
parentf6f254c8f79d727fe3235a746ddd00a4b62e6595 (diff)
wikihelp: wikiconv2 into a module. Don't generate redirects by default.
-rwxr-xr-xhelpcontent2/help-to-wiki.py38
-rwxr-xr-xhelpcontent2/to-wiki/wikiconv2.py157
2 files changed, 113 insertions, 82 deletions
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:
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py
index a160779b04..2392fe4bbe 100755
--- a/helpcontent2/to-wiki/wikiconv2.py
+++ b/helpcontent2/to-wiki/wikiconv2.py
@@ -316,7 +316,7 @@ class XhpFile(ElementBase):
class LocalizedText(ElementBase):
def __init__(self, parser, data, attrs):
# Initialized with some 'tag' such that the parser
- # never needs to access the parent (which in this
+ # never needs to access the parent (which in this
# case is null)
ElementBase.__init__(self, 'localizedtext', None)
header = u'<?xml version="1.0" encoding="UTF-8"?><paragraph>'
@@ -882,7 +882,7 @@ class Paragraph(ElementBase):
except:
self.role = 'paragraph'
- try:
+ try:
self.id = attrs['id']
except:
self.id = ""
@@ -1090,7 +1090,7 @@ def signal_handler(signal, frame):
sys.exit(1)
signal.signal(signal.SIGINT, signal_handler)
-class WikiConv2(Thread):
+class WikiConverter(Thread):
def __init__(self, inputfile, wiki_page_name, outputfile):
Thread.__init__(self)
self.inputfile = inputfile
@@ -1103,46 +1103,6 @@ class WikiConv2(Thread):
file.write(parser.get_all())
file.close()
-# Main Function
-load_hid_lst()
-loadallfiles("alltitles.csv")
-if len(sys.argv) > 1:
- load_localization_data(sys.argv[1])
-
-for title in titles:
- while threading.active_count() > max_threads:
- time.sleep(0.001)
-
- outfile = ""
- infile = ""
- if len(title) > 1:
- outfile = "wiki/"+title[1].strip()
- infile = title[0].strip()
- try:
- file = open(outfile,"r")
- except:
- try:
- wiki = WikiConv2(infile,title[1].strip(),outfile)
- wiki.start()
- continue
- except:
- print 'Failed to convert "%s" into "%s".\n'% \
- (title[1].strip(), outfile)
- print "Warning: Skipping: "+infile+" > "+outfile
- file.close()
-
-# wait for everyone to finish
-while threading.active_count() > 1:
- time.sleep(0.001)
-
-# set of the images used here
-print 'Generating "images.txt", the list of used images...'
-file = open('images.txt', "w")
-for image in images:
- file.write('%s\n'% image)
-file.close()
-
-# generate the redirects
def write_link(r, target):
fname = 'wiki/%s'% r
try:
@@ -1152,40 +1112,87 @@ def write_link(r, target):
except:
sys.stderr.write('Unable to write "%s".\n'%'wiki/%s'% fname)
-print 'Generating the redirects...'
-written = {}
-# in the first pass, immediately writte the links that are embedded, so that
-# we can always point to that source versions
-for redir in redirects:
- app = redir[0]
- redirect = redir[1]
- target = redir[2]
- authoritative = redir[3]
-
- if app != '':
- r = '%s/%s'% (app, redirect)
- if authoritative:
- write_link(r, target)
- written[r] = True
+def write_redirects():
+ print 'Generating the redirects...'
+ written = {}
+ # in the first pass, immediately writte the links that are embedded, so that
+ # we can always point to that source versions
+ for redir in redirects:
+ app = redir[0]
+ redirect = redir[1]
+ target = redir[2]
+ authoritative = redir[3]
+
+ if app != '':
+ r = '%s/%s'% (app, redirect)
+ if authoritative:
+ write_link(r, target)
+ written[r] = True
+ else:
+ try:
+ written[r]
+ except:
+ written[r] = False
+
+ # in the second pass, output the wiki links
+ for redir in redirects:
+ app = redir[0]
+ redirect = redir[1]
+ target = redir[2]
+
+ if app == '':
+ for i in ['swriter', 'scalc', 'simpress', 'sdraw', 'smath', \
+ 'schart', 'sbasic', 'sdatabase']:
+ write_link('%s/%s'% (i, redirect), target)
else:
+ r = '%s/%s'% (app, redirect)
+ if not written[r]:
+ write_link(r, target)
+
+# Main Function
+def convert(generate_redirects, localizations):
+ print "Generating the wiki itself..."
+ load_hid_lst()
+ loadallfiles("alltitles.csv")
+
+ if len(localizations) > 1:
+ load_localization_data(localizations[1])
+
+ for title in titles:
+ while threading.active_count() > max_threads:
+ time.sleep(0.001)
+
+ outfile = ""
+ infile = ""
+ if len(title) > 1:
+ outfile = "wiki/"+title[1].strip()
+ infile = title[0].strip()
try:
- written[r]
+ file = open(outfile,"r")
except:
- written[r] = False
-
-# in the second pass, output the wiki links
-for redir in redirects:
- app = redir[0]
- redirect = redir[1]
- target = redir[2]
-
- if app == '':
- for i in ['swriter', 'scalc', 'simpress', 'sdraw', 'smath', \
- 'schart', 'sbasic', 'sdatabase']:
- write_link('%s/%s'% (i, redirect), target)
- else:
- r = '%s/%s'% (app, redirect)
- if not written[r]:
- write_link(r, target)
+ try:
+ wiki = WikiConverter(infile,title[1].strip(),outfile)
+ wiki.start()
+ continue
+ except:
+ print 'Failed to convert "%s" into "%s".\n'% \
+ (title[1].strip(), outfile)
+ print "Warning: Skipping: "+infile+" > "+outfile
+ file.close()
+
+ # wait for everyone to finish
+ while threading.active_count() > 1:
+ time.sleep(0.001)
+
+ # set of the images used here
+ print 'Generating "images.txt", the list of used images...'
+ file = open('images.txt', "w")
+ for image in images:
+ file.write('%s\n'% image)
+ file.close()
+
+ # generate the redirects
+ if generate_redirects:
+ write_redirects()
# vim:set shiftwidth=4 softtabstop=4 expandtab:
4'>libreoffice-7-5-4 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorThomas Arnhold <thomas@arnhold.org>2012-06-27 13:27:03 +0200
committerThomas Arnhold <thomas@arnhold.org>2012-06-27 13:27:03 +0200
commit51ce86f1ef01ad7719f90776cb1e915166660c3b (patch)
tree513bbc8bd35eae352f51512761fba150851eafb0 /chart2
parentff13378085ccba67ece63afd4cfa62704f582f95 (diff)
Get rid of annoying IAccessibility2 comments
Change-Id: Ic1d7ff88e2d9e638deb2579a5fd18f751302d561