def upgrade_to_epub3(self, tdir, opf): self.log.info('Upgrading to EPUB 3...') from calibre.ebooks.epub import simple_container_xml from calibre.ebooks.oeb.polish.cover import fix_conversion_titlepage_links_in_nav try: os.mkdir(os.path.join(tdir, 'META-INF')) except EnvironmentError: pass with open(os.path.join(tdir, 'META-INF', 'container.xml'), 'wb') as f: f.write( simple_container_xml(os.path.basename(opf)).encode('utf-8')) from calibre.ebooks.oeb.polish.container import EpubContainer container = EpubContainer(tdir, self.log) from calibre.ebooks.oeb.polish.upgrade import epub_2_to_3 existing_nav = getattr(self.opts, 'epub3_nav_parsed', None) nav_href = getattr(self.opts, 'epub3_nav_href', None) previous_nav = (nav_href, existing_nav) if existing_nav and nav_href else None epub_2_to_3(container, self.log.info, previous_nav=previous_nav) fix_conversion_titlepage_links_in_nav(container) container.commit() os.remove(f.name) try: os.rmdir(os.path.join(tdir, 'META-INF')) except EnvironmentError: pass
def upgrade_to_epub3(self, tdir, opf): self.log.info('Upgrading to EPUB 3...') from calibre.ebooks.epub import simple_container_xml try: os.mkdir(os.path.join(tdir, 'META-INF')) except EnvironmentError: pass with open(os.path.join(tdir, 'META-INF', 'container.xml'), 'wb') as f: f.write( simple_container_xml(os.path.basename(opf)).encode('utf-8')) from calibre.ebooks.oeb.polish.container import EpubContainer container = EpubContainer(tdir, self.log) from calibre.ebooks.oeb.polish.upgrade import epub_2_to_3 epub_2_to_3(container, self.log.info) container.commit() os.remove(f.name) try: os.rmdir(os.path.join(tdir, 'META-INF')) except EnvironmentError: pass
def upgrade_to_epub3(self, tdir, opf): self.log.info('Upgrading to EPUB 3...') from calibre.ebooks.epub import simple_container_xml from calibre.ebooks.oeb.polish.cover import fix_conversion_titlepage_links_in_nav try: os.mkdir(os.path.join(tdir, 'META-INF')) except EnvironmentError: pass with open(os.path.join(tdir, 'META-INF', 'container.xml'), 'wb') as f: f.write(simple_container_xml(os.path.basename(opf)).encode('utf-8')) from calibre.ebooks.oeb.polish.container import EpubContainer container = EpubContainer(tdir, self.log) from calibre.ebooks.oeb.polish.upgrade import epub_2_to_3 existing_nav = getattr(self.opts, 'epub3_nav_parsed', None) nav_href = getattr(self.opts, 'epub3_nav_href', None) previous_nav = (existing_nav, nav_href) if existing_nav and nav_href else None epub_2_to_3(container, self.log.info, previous_nav=previous_nav) fix_conversion_titlepage_links_in_nav(container) container.commit() os.remove(f.name) try: os.rmdir(os.path.join(tdir, 'META-INF')) except EnvironmentError: pass