view examples/transform/run.py @ 170:6b265e02d099 trunk

Allow initialization of `Attributes` with keyword arguments.
author cmlenz
date Fri, 18 Aug 2006 12:40:55 +0000
parents 61f58e3a123d
children 84168828b074
line wrap: on
line source
#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys

from markup.input import HTMLParser
from markup.template import Context, Template

def transform(html_filename, tmpl_filename):
    tmpl_fileobj = open(tmpl_filename)
    tmpl = Template(tmpl_fileobj, tmpl_filename)
    tmpl_fileobj.close()

    html_fileobj = open(html_filename)
    html = HTMLParser(html_fileobj, html_filename)
    print tmpl.generate(Context(input=html)).render('xhtml')
    html_fileobj.close()

if __name__ == '__main__':
    basepath = os.path.dirname(os.path.abspath(__file__))
    tmpl_filename = os.path.join(basepath, 'template.xml')
    html_filename = os.path.join(basepath, 'index.html')
    transform(html_filename, tmpl_filename)
Copyright (C) 2012-2017 Edgewall Software