當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。