X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=doc%2Fchm-toc-modifier.py;h=38f25e2dcefd039a509be5ffec30672d59678862;hb=57dfb183e24175bc782647d4e6aebe31063f3881;hp=f6239c8ce79949bbee0696ce7e9133605d3e5e7f;hpb=34bc08f544f7745e99bdb9197c390701bdee5e4b;p=bertos.git diff --git a/doc/chm-toc-modifier.py b/doc/chm-toc-modifier.py index f6239c8c..38f25e2d 100644 --- a/doc/chm-toc-modifier.py +++ b/doc/chm-toc-modifier.py @@ -1,44 +1,44 @@ -from __future__ import with_statement -import sys, re - -if len(sys.argv) < 1: - print "Usage: " + sys.argv[0] + " [hhc index file] [output file]" - sys.exit(-1) - -outfile = "out.hhc" -if len(sys.argv) == 3: - outfile = sys.argv[2] - -data_structures = [] - -section_start = re.compile(r"
  • .*? value=\"((File List)|(Data Structures)|(Main Page)|(Directory Hierarchy))\".*$") - -data_section = False -file_section = False - -with open(sys.argv[1], "r") as f: - with open(outfile, "w+") as out: - for line in f: - if re.search(section_start, line): - if line.find("Data Structures") != -1: - data_section = True - file_section = False - elif line.find("File List") != -1: - data_section = False - file_section = True - else: - data_section = False - file_section = False - - if data_section: - data_structures.append(line) - elif file_section: - pass - elif re.search(r"^<\/UL>$", line): - for i in data_structures: - out.write(i) - out.write(line) - else: - out.write(line) - - +from __future__ import with_statement +import sys, re + +if len(sys.argv) < 1: + print "Usage: " + sys.argv[0] + " [hhc index file] [output file]" + sys.exit(-1) + +outfile = "out.hhc" +if len(sys.argv) == 3: + outfile = sys.argv[2] + +data_structures = [] + +section_start = re.compile(r"
  • .*? value=\"((File List)|(Data Structures)|(Main Page)|(Directory Hierarchy))\".*$") + +data_section = False +file_section = False + +with open(sys.argv[1], "r") as f: + with open(outfile, "w+") as out: + for line in f: + if re.search(section_start, line): + if line.find("Data Structures") != -1: + data_section = True + file_section = False + elif line.find("File List") != -1: + data_section = False + file_section = True + else: + data_section = False + file_section = False + + if data_section: + data_structures.append(line) + elif file_section: + pass + elif re.search(r"^<\/UL>$", line): + for i in data_structures: + out.write(i) + out.write(line) + else: + out.write(line) + +