#!/usr/bin/env python ############################################################################ # # MODULE: mkhtml.py # AUTHOR(S): Markus Neteler, Glynn Clements # PURPOSE: create HTML manual page snippets # COPYRIGHT: (C) 2007,2009 Glynn Clements and the GRASS Development Team # # This program is free software under the GNU General Public # License (>=v2). Read the file COPYING that comes with GRASS # for details. # ############################################################################# import sys import os import string import re pgm = sys.argv[1] src_file = "%s.html" % pgm tmp_file = "%s.tmp.html" % pgm header_tmpl = string.Template(\ """
Main index - $INDEXNAME index - Full index
© 2003-2009 GRASS Development Team
""") def read_file(name): try: f = open(name, 'rb') s = f.read() f.close() return s except IOError: return "" src_data = read_file(src_file) if not re.search('', src_data, re.IGNORECASE): tmp_data = read_file(tmp_file) if not re.search('', tmp_data, re.IGNORECASE): sys.stdout.write(header_tmpl.substitute(PGM = pgm)) if tmp_data: for line in tmp_data.splitlines(True): if not re.search('|', line, re.IGNORECASE): sys.stdout.write(line) sys.stdout.write(src_data) # if