home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from __future__ import with_statement
- __license__ = 'GPL 3'
- __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
- __docformat__ = 'restructuredtext en'
- import os
- import re
- from lxml import etree
- from calibre.customize.conversion import OutputFormatPlugin
- from calibre import CurrentDir
- from calibre.customize.conversion import OptionRecommendation
- from urllib import unquote
-
- class OEBOutput(OutputFormatPlugin):
- name = 'OEB Output'
- author = 'Kovid Goyal'
- file_type = 'oeb'
- recommendations = set([
- ('pretty_print', True, OptionRecommendation.HIGH)])
-
- def convert(self, oeb_book, output_path, input_plugin, opts, log):
- self.log = log
- self.opts = opts
- if not os.path.exists(output_path):
- os.makedirs(output_path)
-
- OPF_MIME = OPF_MIME
- NCX_MIME = NCX_MIME
- PAGE_MAP_MIME = PAGE_MAP_MIME
- import calibre.ebooks.oeb.base
- CurrentDir(output_path).__enter__()
-
- try:
- results = oeb_book.to_opf2(page_map = True)
- for key in (OPF_MIME, NCX_MIME, PAGE_MAP_MIME):
- (href, root) = results.pop(key, [
- None,
- None])
- if root is not None:
- raw = etree.tostring(root, pretty_print = True, encoding = 'utf-8', xml_declaration = True)
-
- try:
- f = _[1]
- f.write(raw)
- finally:
- pass
-
- continue
- open(href, 'wb').__exit__
-
- for item in oeb_book.manifest:
- path = os.path.abspath(unquote(item.href))
- dir = os.path.dirname(path)
-
- try:
- f = _[2]
- f.write(str(item))
- finally:
- pass
-
- item.unload_data_from_memory(memory = path)
- finally:
- pass
-
-
-
-