home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_982 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.0 KB  |  53 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. __license__ = 'GPL 3'
  6. __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
  7. __docformat__ = 'restructuredtext en'
  8. from calibre.customize.conversion import InputFormatPlugin
  9.  
  10. class MOBIInput(InputFormatPlugin):
  11.     name = 'MOBI Input'
  12.     author = 'Kovid Goyal'
  13.     description = 'Convert MOBI files (.mobi, .prc, .azw) to HTML'
  14.     file_types = set([
  15.         'mobi',
  16.         'prc',
  17.         'azw'])
  18.     
  19.     def convert(self, stream, options, file_ext, log, accelerators):
  20.         MobiReader = MobiReader
  21.         import calibre.ebooks.mobi.reader
  22.         html = html
  23.         import lxml
  24.         parse_cache = { }
  25.         
  26.         try:
  27.             mr = MobiReader(stream, log, options.input_encoding, options.debug_pipeline)
  28.             mr.extract_content('.', parse_cache)
  29.         except:
  30.             mr = MobiReader(stream, log, options.input_encoding, options.debug_pipeline, try_extra_data_fix = True)
  31.             mr.extract_content('.', parse_cache)
  32.  
  33.         raw = parse_cache.pop('calibre_raw_mobi_markup', False)
  34.         if raw:
  35.             if isinstance(raw, unicode):
  36.                 raw = raw.encode('utf-8')
  37.             
  38.             open('debug-raw.html', 'wb').write(raw)
  39.         
  40.         for f, root in parse_cache.items():
  41.             
  42.             try:
  43.                 q = _[1]
  44.                 q.write(html.tostring(root, encoding = 'utf-8', method = 'xml', include_meta_content_type = False))
  45.                 accelerators['pagebreaks'] = '//h:div[@class="mbp_pagebreak"]'
  46.             finally:
  47.                 pass
  48.  
  49.         
  50.         return mr.created_opf_path
  51.  
  52.  
  53.