home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1071 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.6 KB  |  37 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.rb.writer import RBWriter
  10.  
  11. class RBOutput(OutputFormatPlugin):
  12.     name = 'RB Output'
  13.     author = 'John Schember'
  14.     file_type = 'rb'
  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.     
  18.     def convert(self, oeb_book, output_path, input_plugin, opts, log):
  19.         close = False
  20.         if not hasattr(output_path, 'write'):
  21.             close = True
  22.             if not os.path.exists(os.path.dirname(output_path)) and os.path.dirname(output_path) != '':
  23.                 os.makedirs(os.path.dirname(output_path))
  24.             
  25.             out_stream = open(output_path, 'wb')
  26.         else:
  27.             out_stream = output_path
  28.         writer = RBWriter(opts, log)
  29.         out_stream.seek(0)
  30.         out_stream.truncate()
  31.         writer.write_content(oeb_book, out_stream, oeb_book.metadata)
  32.         if close:
  33.             out_stream.close()
  34.         
  35.  
  36.  
  37.