1
#!/usr/bin/env python2.4
4
from StringIO import StringIO
7
from docutils.core import publish_file
8
from docutils.parsers import rst
9
from elementtree.ElementTree import XML
12
def kidified_rest(rest_file, template_name):
13
xhtml = publish_file(rest_file, writer_name='html', destination=StringIO())
15
head = xml.find('{http://www.w3.org/1999/xhtml}head')
16
body = xml.find('{http://www.w3.org/1999/xhtml}body')
17
assert head is not None
18
assert body is not None
19
template=kid.Template(file=template_name,
21
return (template.serialize())
23
def safe_open(filename, mode):
25
return open(filename, mode + 'b')
27
if e.errno != errno.ENOENT:
29
sys.stderr.write('file not found: %s\n' % sys.argv[2])
36
rest_file = safe_open(args[1], 'r')
41
out_file = safe_open(args[2], 'w')
45
out_file.write(kidified_rest(rest_file, args[0]))