home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_887 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  2.0 KB  |  42 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL 3'
  5. __copyright__ = '2009, John Schember <john@nachtimwald.com>'
  6. __docformat__ = 'restructuredtext en'
  7. import os
  8. from calibre.customize.conversion import OutputFormatPlugin, OptionRecommendation
  9. from calibre.ebooks.fb2.fb2ml import FB2MLizer
  10.  
  11. class FB2Output(OutputFormatPlugin):
  12.     name = 'FB2 Output'
  13.     author = 'John Schember'
  14.     file_type = 'fb2'
  15.     options = set([
  16.         OptionRecommendation(name = 'inline_toc', recommended_value = False, level = OptionRecommendation.LOW, help = _('Add Table of Contents to beginning of the book.')),
  17.         OptionRecommendation(name = 'sectionize_chapters', recommended_value = False, level = OptionRecommendation.LOW, help = _('Try to turn chapters into individual sections. WARNING: This option is experimental. It can cause conversion to fail. It can also produce unexpected output.'))])
  18.     
  19.     def convert(self, oeb_book, output_path, input_plugin, opts, log):
  20.         linearize_jacket = linearize_jacket
  21.         import calibre.ebooks.oeb.transforms.jacket
  22.         linearize_jacket(oeb_book)
  23.         fb2mlizer = FB2MLizer(log)
  24.         fb2_content = fb2mlizer.extract_content(oeb_book, opts)
  25.         close = False
  26.         if not hasattr(output_path, 'write'):
  27.             close = True
  28.             if not os.path.exists(os.path.dirname(output_path)) and os.path.dirname(output_path) != '':
  29.                 os.makedirs(os.path.dirname(output_path))
  30.             
  31.             out_stream = open(output_path, 'wb')
  32.         else:
  33.             out_stream = output_path
  34.         out_stream.seek(0)
  35.         out_stream.truncate()
  36.         out_stream.write(fb2_content.encode('utf-8', 'replace'))
  37.         if close:
  38.             out_stream.close()
  39.         
  40.  
  41.  
  42.