summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuthu Subramanian K <sumuthu@novell.com>2010-11-12 22:51:41 +0530
committerMuthu Subramanian K <sumuthu@novell.com>2010-11-12 22:51:41 +0530
commit0597d5c61924b61e47c51a455ec537c8fc4dd251 (patch)
tree4ed8b37ade80af0d599a61b7f94408064b9830ac
parent69406254e263e6adee4323499083af10d759006a (diff)
Updated to generated bookmarks.h file instead of a csv.
-rwxr-xr-xhelpcontent2/help-to-wiki.py42
-rwxr-xr-xhelpcontent2/to-wiki/wikiconv2.py37
2 files changed, 76 insertions, 3 deletions
diff --git a/helpcontent2/help-to-wiki.py b/helpcontent2/help-to-wiki.py
index a0e45a61b1..59a893518a 100755
--- a/helpcontent2/help-to-wiki.py
+++ b/helpcontent2/help-to-wiki.py
@@ -2,6 +2,27 @@
import sys, os
+header_template = "\n\
+// This file is generated using the Wiki Converter \n\
+// Please exercise caution while modifying this file directly \n\
+#ifndef __BOOKMARKS_H__\n\
+#define __BOOKMARKS_H__\n\
+\n\
+typedef struct WIKI_LINKS_MAP {\n\
+ ULONG id; // HELP ID\n\
+ const char *link; // Mapped Wiki Link\n\
+} WikiLinksMap;\n\
+\n\
+static WikiLinksMap aWikiMaps[] = {\n\
+"
+
+footer_template = "\
+ { 0, \"\" }\n\
+};\n\
+\n\
+#endif\n\
+"
+
# FIXME do proper modules from getalltitles & wikiconv2
# [so far this is in fact just a shell thing]
@@ -29,11 +50,32 @@ def create_wiki_dirs():
except:
pass
+def create_wiki_header():
+ try:
+ file = open( "bookmarks.h", "r" )
+ file.close()
+ sys.stdout.write( "bookmarks.h already exists! Ignoring...\n" )
+ except:
+ file = open( "bookmarks.h", "w" )
+ file.write( header_template )
+ file.close()
+
+def create_wiki_footer():
+ file = open( "bookmarks.h", "a" )
+ file.write( footer_template )
+ file.close()
+
# do the work
create_wiki_dirs()
+# create bookmarks.h template
+create_wiki_header()
+
print "Generating the titles..."
os.system( "python to-wiki/getalltitles.py source/text > alltitles.csv" )
print "Generating the wiki itself..."
os.system( "python to-wiki/convall.py source/text" )
+
+# close the bookmarks.h template
+create_wiki_footer()
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py
index 314e3e93af..d419f1ff60 100755
--- a/helpcontent2/to-wiki/wikiconv2.py
+++ b/helpcontent2/to-wiki/wikiconv2.py
@@ -93,6 +93,32 @@ help_id_patterns = [
help_file_name = ""
+all_help_id_mappings = [[]]
+
+def load_all_help_ids():
+ file = open("helpers/help_hid.lst")
+ for line in file:
+ ids = line.strip().upper().split(",")
+ if len(ids) >= 2:
+ all_help_id_mappings.append(ids)
+
+def get_help_id_res2(name):
+ file = open("helpers/hid.lst")
+ for line in file:
+ ids = line.strip().upper().split(" ")
+ if len(ids) >= 2:
+ if ids[0] == name:
+ return ids[1]
+ # if none found
+ return "0"
+
+def get_help_id(name):
+ name = name.strip().replace("cui_","svx_").upper()
+ for i in all_help_id_mappings:
+ if len(i) >= 2 and i[0].strip() == name:
+ return i[1].strip()
+ return get_help_id_res2(name)
+
def get_link_filename(link, name):
text = link
if link.find("http") >= 0:
@@ -239,16 +265,17 @@ class cbookmark:
if data.find("]]") >= 0:
try:
data = data[data.find("|")+1:data.find("]]")]
- data = data.replace("cui_","svx_")
except:
pass
- bookmark = cbookmark.current_bookmark+";"+help_file_name+"#"+data
+ help_id = get_help_id(cbookmark.current_bookmark)
+ bookmark = " { "+help_id+", \""+help_file_name+"#"+data.replace("\"","\\\"")+"\" },"
+ bookmark = bookmark.encode('ascii','replace')
cbookmark.bookmarks_list.append(bookmark)
cbookmark.current_bookmark = ""
@staticmethod
def save_bookmarks():
- file = open("bookmarks.csv","a")
+ file = open("bookmarks.h","a")
for i in cbookmark.bookmarks_list:
file.write(i.encode('ascii','replace')+"\n")
file.close()
@@ -686,6 +713,10 @@ if len(sys.argv) < 2:
if len(sys.argv) > 2:
help_file_name = sys.argv[2]
+# 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.
+load_all_help_ids()
loadallfiles("alltitles.csv")
parsexhp(sys.argv[1])
print head_obj.get_all().encode('ascii','replace')