home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1134 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.6 KB  |  52 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 InputFormatPlugin, OptionRecommendation
  9. from calibre.ebooks.txt.processor import convert_basic, opf_writer, separate_paragraphs_single_line, separate_paragraphs_print_formatted
  10. from calibre.ebooks.compression.tcr import decompress
  11.  
  12. class TCRInput(InputFormatPlugin):
  13.     name = 'TCR Input'
  14.     author = 'John Schember'
  15.     description = 'Convert TCR files to HTML'
  16.     file_types = set([
  17.         'tcr'])
  18.     options = set([
  19.         OptionRecommendation(name = 'single_line_paras', recommended_value = False, help = _('Normally calibre treats blank lines as paragraph markers. With this option it will assume that every line represents a paragraph instead.')),
  20.         OptionRecommendation(name = 'print_formatted_paras', recommended_value = False, help = _('Normally calibre treats blank lines as paragraph markers. With this option it will assume that every line starting with an indent (either a tab or 2+ spaces) represents a paragraph. Paragraphs end when the next line that starts with an indent is reached.'))])
  21.     
  22.     def convert(self, stream, options, file_ext, log, accelerators):
  23.         log.info('Decompressing text...')
  24.         ienc = None if options.input_encoding else 'utf-8'
  25.         txt = decompress(stream).decode(ienc, 'replace')
  26.         log.info('Converting text to OEB...')
  27.         if options.single_line_paras:
  28.             txt = separate_paragraphs_single_line(txt)
  29.         
  30.         if options.print_formatted_paras:
  31.             txt = separate_paragraphs_print_formatted(txt)
  32.         
  33.         html = convert_basic(txt)
  34.         
  35.         try:
  36.             index = _[1]
  37.             index.write(html.encode('utf-8'))
  38.         finally:
  39.             pass
  40.  
  41.         get_metadata = get_metadata
  42.         import calibre.ebooks.metadata.meta
  43.         mi = get_metadata(stream, 'tcr')
  44.         manifest = [
  45.             ('index.html', None)]
  46.         spine = [
  47.             'index.html']
  48.         opf_writer(os.getcwd(), 'metadata.opf', manifest, spine, mi)
  49.         return os.path.join(os.getcwd(), 'metadata.opf')
  50.  
  51.  
  52.