Logo Search packages:      
Sourcecode: calibre version File versions  Download package

def calibre.customize.builtins.HTML2ZIP.run (   self,
Run the plugin. Must be implemented in subclasses.
It should perform whatever modifications are required
on the ebook and return the absolute path to the
modified ebook. If no modifications are needed, it should
return the path to the original ebook. If an error is encountered
it should raise an Exception. The default implementation
simply return the path to the original ebook.

The modified ebook file should be created with the
:meth:`temporary_file` method.

:param path_to_ebook: Absolute path to the ebook.

:return: Absolute path to the modified ebook.

Reimplemented from calibre.customize.FileTypePlugin.

Definition at line 25 of file builtins.py.

References calibre.customize.Plugin.site_customization, and calibre.customize.Plugin.temporary_file().

    def run(self, htmlfile):
        from calibre.ptempfile import TemporaryDirectory
        from calibre.gui2.convert.gui_conversion import gui_convert
        from calibre.customize.conversion import OptionRecommendation
        from calibre.ebooks.epub import initialize_container

        with TemporaryDirectory('_plugin_html2zip') as tdir:
            recs =[('debug_pipeline', tdir, OptionRecommendation.HIGH)]
            recs.append(['keep_ligatures', True, OptionRecommendation.HIGH])
            if self.site_customization and self.site_customization.strip():
                recs.append(['input_encoding', self.site_customization.strip(),
            gui_convert(htmlfile, tdir, recs, abort_after_input_dump=True)
            of = self.temporary_file('_plugin_html2zip.zip')
            tdir = os.path.join(tdir, 'input')
            opf = glob.glob(os.path.join(tdir, '*.opf'))[0]
            ncx = glob.glob(os.path.join(tdir, '*.ncx'))
            if ncx:
            epub = initialize_container(of.name, os.path.basename(opf))

        return of.name

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index