当前位置: 首页>>代码示例>>Python>>正文


Python Renderer.cleanup方法代码示例

本文整理汇总了Python中plasTeX.Renderers.PageTemplate.Renderer.cleanup方法的典型用法代码示例。如果您正苦于以下问题:Python Renderer.cleanup方法的具体用法?Python Renderer.cleanup怎么用?Python Renderer.cleanup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plasTeX.Renderers.PageTemplate.Renderer的用法示例。


在下文中一共展示了Renderer.cleanup方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cleanup

# 需要导入模块: from plasTeX.Renderers.PageTemplate import Renderer [as 别名]
# 或者: from plasTeX.Renderers.PageTemplate.Renderer import cleanup [as 别名]
 def cleanup(self, document, files, postProcess=None):
     res = _Renderer.cleanup(self, document, files, postProcess=postProcess)
     self.doJavaHelpFiles(document, version='1')
     self.doJavaHelpFiles(document, version='2')
     self.doEclipseHelpFiles(document)
     self.doCHMFiles(document)
     return res
开发者ID:AllenDowney,项目名称:plastex-oreilly,代码行数:9,代码来源:__init__.py

示例2: cleanup

# 需要导入模块: from plasTeX.Renderers.PageTemplate import Renderer [as 别名]
# 或者: from plasTeX.Renderers.PageTemplate.Renderer import cleanup [as 别名]
    def cleanup(self, document, files, postProcess=None):
        """
        Cleanup method called at the end of rendering.
        Uses the base renderer cleanup but calls packages callbacks before and
        after. Callbacks should be listed in
        document.userdata['preCleanupCallbacks']
        or document.userdata['postCleanupCallbacks']. Each call back should accept the
        current document as its only argument. Pre-cleanup call back must return
        the list of path of files they created (relative to the output directory).
        """

        rendererdata = document.rendererdata.get('html5', dict())
        preCleanupCallbacks = rendererdata.get('preCleanupCallbacks', [])
        for preCleanupCallback in preCleanupCallbacks:
            files += preCleanupCallback(document)

        _Renderer.cleanup(self, document, files, postProcess)
开发者ID:PatrickMassot,项目名称:plastex,代码行数:19,代码来源:__init__.py

示例3: cleanup

# 需要导入模块: from plasTeX.Renderers.PageTemplate import Renderer [as 别名]
# 或者: from plasTeX.Renderers.PageTemplate.Renderer import cleanup [as 别名]
 def cleanup(self, document, files, postProcess=None):
     res = _Renderer.cleanup(self, document, files, postProcess=postProcess)
     return res
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:5,代码来源:__init__.py

示例4: cleanup

# 需要导入模块: from plasTeX.Renderers.PageTemplate import Renderer [as 别名]
# 或者: from plasTeX.Renderers.PageTemplate.Renderer import cleanup [as 别名]
    def cleanup(self, document, files, postProcess=None):        
        res = _Renderer.cleanup(self, document, files, postProcess=postProcess)

        # Define uma lista de arquivos que devem ficar fora de OEBPS/,
        # e move os outros arquivos / diretórios, apagando os diretórios
        # pré-existentes em OEBPS/
        dirNaoMover = ['mimetype', 'OEBPS', 'META-INF', 'Makefile']
        moverDirs = list(set(os.listdir('.')) - set(dirNaoMover))
        for arq in moverDirs:
            if os.path.isdir('OEBPS/%s' % arq):
                shutil.rmtree('OEBPS/%s' % arq)
            shutil.move(arq, 'OEBPS/%s' % arq)

        # Move os arquivos de conteúdo para OEBPS/
#        for arq in files:
#            os.rename(arq, 'OEBPS/' + arq)

        # Mover todos os arquivos e diretórios que não sejam o META-INF/, OEBPS/ e mimetype

        latexdoc = document.getElementsByTagName('document')[0]

        # Cria uma entrada para o bookid com um UUID aleatório.
        latexdoc.setUserData('bookid', 'urn:uuid:%s' % uuid.uuid4())

        # Adiciona o mimetype do arquivo ncx
        if not mimetypes.types_map.has_key('.ncx'):
            mimetypes.add_type('application/x-dtbncx+xml', '.ncx')

        # Mimetypes dos arquivos .html, .svg e .otf
        mimetypes.add_type('application/xhtml+xml', '.html')
        mimetypes.add_type('image/svg+xml', '.svg')
        mimetypes.add_type('application/vnd.ms-opentype', '.otf')

        # Gera o arquivo ncx
        self.doNCXFiles(latexdoc)

        listaArquivos = dict() # Lista dos arquivos no manifest
        spine = [] # Lista de ids no spine (poderiamos trocar por uma função que verifica quais tipos de seção geram arquivos e incluir no userdata deles).
        for root, dirs, arquivos in os.walk('OEBPS/'):
            for nomeArquivo in arquivos:
                if (nomeArquivo == 'content.opf'):
                    continue

                if re.match('.*~$', nomeArquivo):
                    continue

                href = os.path.join(re.sub('OEBPS/?', '', root), nomeArquivo)
                # As / são substituídas por - no id
                itemid = re.sub('[/.]', '-', href)
                mediaType = mimetypes.guess_type(nomeArquivo)[0]

                # Os arquivos html são incluídos no spine
                if re.match('.*\.html', nomeArquivo):
                    spine.append(itemid)

                listaArquivos[itemid] = {'href': href, 'mediaType': mediaType}
            
        latexdoc.setUserData('listaArqs', listaArquivos)
        # A lista de ids será ordenada para a geração do content.opf
        latexdoc.setUserData('spine', sorted(spine))

        # Chamadas para geração do arquivo opf
        self.doOPFFiles(latexdoc)
        return res
开发者ID:marcio-curl,项目名称:EPUB-plasTeX,代码行数:66,代码来源:__init__.py

示例5: cleanup

# 需要导入模块: from plasTeX.Renderers.PageTemplate import Renderer [as 别名]
# 或者: from plasTeX.Renderers.PageTemplate.Renderer import cleanup [as 别名]
    def cleanup(self, document, files, postProcess=None):
        res = _Renderer.cleanup(self, document, files, postProcess=postProcess)

        # TODO: Convert this to named registered utilities or adapters
        self.doEclipseHelpFiles(document)
        return res
开发者ID:NextThought,项目名称:nti.plasTeX,代码行数:8,代码来源:__init__.py


注:本文中的plasTeX.Renderers.PageTemplate.Renderer.cleanup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。