Пример #1
0
def write_oebbook(oeb, path):
    from calibre.ebooks.oeb.writer import OEBWriter
    from calibre import walk
    w = OEBWriter()
    w(oeb, path)
    for f in walk(path):
        if f.endswith('.opf'):
            return f
Пример #2
0
 def _cover_from_html(self, hcover):
     from calibre.ebooks import render_html_svg_workaround
     with TemporaryDirectory('_html_cover') as tdir:
         writer = OEBWriter()
         writer(self.oeb, tdir)
         path = os.path.join(tdir, urlunquote(hcover.href))
         data = render_html_svg_workaround(path, self.logger)
         if not data:
             data = ''
     id, href = self.oeb.manifest.generate('cover', 'cover.jpg')
     item = self.oeb.manifest.add(id, href, JPEG_MIME, data=data)
     return item