def odt_template(fn, ctx, page_size="A4"):
inp = zipfile.ZipFile(fn, "r" )
outs = StringIO.StringIO()
output = zipfile.ZipFile(outs, "a" )
for zi in inp.filelist:
out = inp.read(zi.filename)
if zi.filename == 'content.xml': # waut for the only interesting file
# un-escape the quotes (in filters etc.)
t = Template(out.replace( '"', '"' ))
out = t.render(ctx).encode('utf8')
if page_size=="US" and zi.filename == 'styles.xml' :
t = Template(out.replace( 'style:page-layout-properties fo:page-width="297mm" fo:page-height="210.01mm"', 'style:page-layout-properties fo:page-width="279.4mm" fo:page-height="215.9mm"' ))
out = t.render(ctx).encode('utf8')
output.writestr(zi.filename, out)
output.close()
content=outs.getvalue()
return content
#from celery.task.control import inspect
#i = inspect()
#i.scheduled()
#i.active()
评论列表
文章目录