cmlenz@107: #!/usr/bin/python cmlenz@107: # -*- coding: utf-8 -*- cmlenz@107: cmlenz@107: import os cmlenz@108: import sys cmlenz@107: cmlenz@107: from markup.input import HTMLParser cmlenz@108: from markup.template import Context, Template cmlenz@107: cmlenz@108: def transform(html_filename, tmpl_filename): cmlenz@108: tmpl_fileobj = open(tmpl_filename) cmlenz@108: tmpl = Template(tmpl_fileobj, tmpl_filename) cmlenz@108: tmpl_fileobj.close() cmlenz@108: cmlenz@107: html_fileobj = open(html_filename) cmlenz@108: html = HTMLParser(html_fileobj, html_filename) cmlenz@108: print tmpl.generate(Context(input=html)).render('xhtml') cmlenz@108: html_fileobj.close() cmlenz@107: cmlenz@107: if __name__ == '__main__': cmlenz@108: basepath = os.path.dirname(os.path.abspath(__file__)) cmlenz@108: tmpl_filename = os.path.join(basepath, 'template.xml') cmlenz@108: html_filename = os.path.join(basepath, 'index.html') cmlenz@108: transform(html_filename, tmpl_filename)