home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from __future__ import with_statement
- __license__ = 'GPL v3'
- __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
- __docformat__ = 'restructuredtext en'
- from calibre.customize.conversion import InputFormatPlugin
-
- class LITInput(InputFormatPlugin):
- name = 'LIT Input'
- author = 'Marshall T. Vandegrift'
- description = 'Convert LIT files to HTML'
- file_types = set([
- 'lit'])
-
- def convert(self, stream, options, file_ext, log, accelerators):
- LitReader = LitReader
- import calibre.ebooks.lit.reader
- create_oebbook = create_oebbook
- import calibre.ebooks.conversion.plumber
- return create_oebbook(log, stream, options, self, reader = LitReader)
-
-
- def postprocess_book(self, oeb, opts, log):
- XHTML_NS = XHTML_NS
- XPath = XPath
- XHTML = XHTML
- import calibre.ebooks.oeb.base
- for item in oeb.spine:
- root = item.data
- if not hasattr(root, 'xpath'):
- continue
-
- for bad in ('metadata', 'guide'):
- metadata = XPath('//h:' + bad)(root)
- if metadata:
- for x in metadata:
- x.getparent().remove(x)
-
-
- body = XPath('//h:body')(root)
- if body:
- body = body[0]
- if len(body) == 1 and body[0].tag == XHTML('pre'):
- pre = body[0]
- convert_basic = convert_basic
- import calibre.ebooks.txt.processor
- etree = etree
- import lxml
- import copy
- html = convert_basic(pre.text).replace('<html>', '<html xmlns="%s">' % XHTML_NS)
- root = etree.fromstring(html)
- body = XPath('//h:body')(root)
- pre.tag = XHTML('div')
- pre.text = ''
- for elem in body:
- ne = copy.deepcopy(elem)
- pre.append(ne)
-
-
- body[0].tag == XHTML('pre')
-
-
-
-