cfdilib.py 文件源码

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

项目:cfdilib 作者: Vauxoo 项目源码 文件源码
def set_xml(self):
        """Set document xml just rendered already
        validated against xsd to be signed.

        :params boolean debug_mode: Either if you want
            the rendered template to be saved either it
        is valid or not with the given schema.
        :returns boolean: Either was valid or not the generated document.
        """
        cached = StringIO()
        document = u''
        try:
            document = self.template.render(inv=self)
        except UndefinedError as ups:
            self.ups = ups

        # TODO: Here should be called the cleanup 'Just before the validation'.
        valid = self.validate(self.schema, document)
        self.document = document
        if valid:
            document = etree.XML(document)
            self.document = etree.tostring(document,
                                           pretty_print=True,
                                           xml_declaration=True,
                                           encoding='utf-8')
            # TODO: When Document Generated, this this should not fail either.
            # Caching just when valid then.
            cached.write(self.document is not None and self.document or u'')
            cached.seek(0)
            self.document_path = cached
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号