#!/usr/bin/python # # pchack.py: Process output of ht2html to allow output to # be used as a string substitution template # import sys, re dlstart = "" dlend = "" pat = re.compile("(.+)%s(.+)%s(.+)" % (dlstart, dlend), re.DOTALL) ipf = sys.argv[1] opf = sys.argv[2] txt = file(ipf).read() mtch = pat.match(txt) if not mtch: sys.exit("%s %s" (f, 'did not contain template delimiters')) o = file(opf, "w") o.write(mtch.group(1).replace("%", "%%").replace("../css", "css")) o.write(dlstart) o.write(mtch.group(2)) o.write(dlend) o.write(mtch.group(3).replace("%", "%%")) o.close()