cmlenz@107: #!/usr/bin/python cmlenz@107: # -*- coding: utf-8 -*- cmlenz@107: cmlenz@107: import os cmlenz@108: import sys cmlenz@107: cmlenz@230: from genshi.input import HTMLParser cmlenz@233: from genshi.template import Context, MarkupTemplate cmlenz@107: cmlenz@108: def transform(html_filename, tmpl_filename): cmlenz@108: tmpl_fileobj = open(tmpl_filename) cmlenz@233: tmpl = MarkupTemplate(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)