tasks.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:bctip 作者: norn 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号