home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1078 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.4 KB  |  36 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.ebooks.rtf.rtfml import RTFMLizer
  9. from calibre.customize.conversion import OutputFormatPlugin
  10.  
  11. class RTFOutput(OutputFormatPlugin):
  12.     name = 'RTF Output'
  13.     author = 'John Schember'
  14.     file_type = 'rtf'
  15.     
  16.     def convert(self, oeb_book, output_path, input_plugin, opts, log):
  17.         rtfmlitzer = RTFMLizer(log)
  18.         content = rtfmlitzer.extract_content(oeb_book, opts)
  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.         out_stream.seek(0)
  29.         out_stream.truncate()
  30.         out_stream.write(content.encode('ascii', 'replace'))
  31.         if close:
  32.             out_stream.close()
  33.         
  34.  
  35.  
  36.