wikidoc.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import sys,os
00004 
00005 def usage():
00006     print "Usage:", sys.argv[0], "<wikiname> <htmlname>"
00007     print ""
00008     print "Replaces wiki documentation with documentation from html files"
00009 
00010 def wikidoc(pagename, htmlfile):
00011     f = open(htmlfile)
00012     doclines = f.readlines()
00013     f.close()
00014 
00015     starttag = "<!-- WIKIDOC START -->"
00016     endtag   = "<!-- WIKIDOC END -->"
00017     doclines.insert(0, starttag + '\n')
00018     doclines.append('\n' + endtag + '\n')
00019 
00020     wikilines = []
00021     if os.path.exists(pagename):
00022         f = open(pagename)
00023         wikilines = f.readlines()
00024         f.close()
00025 
00026     startline = -1
00027     endline = -1
00028     for i in range(len(wikilines)):
00029         if wikilines[i].strip() == starttag and startline == -1: startline = i
00030         if wikilines[i].strip() == endtag   and endline == -1:   endline = i
00031 
00032     if startline == -1 or endline == -1 or startline >= endline:
00033         print "Wikidoc warning: Didn't find tags for", pagename
00034         startline = 0
00035         endline = 0
00036 
00037     wikilines = wikilines[:startline] + doclines + wikilines[endline+1:]
00038     f = open(pagename, 'w')
00039     f.writelines(wikilines)
00040     f.close()
00041 
00042 if __name__ == '__main__':
00043     if len(sys.argv) != 3:
00044         usage()
00045         sys.exit(2)
00046 
00047     print "wikidoc: using", sys.argv[1], "for page", sys.argv[2]
00048     wikidoc(sys.argv[1], sys.argv[2])


libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:51