home *** CD-ROM | disk | FTP | other *** search
Wrap
# 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' class Clean(object): def __call__(self, oeb, opts): urldefrag = urldefrag import calibre.ebooks.oeb.base self.oeb = oeb self.log = oeb.log self.opts = opts if 'cover' not in self.oeb.guide: covers = [] for x in ('other.ms-coverimage-standard', 'other.ms-titleimage-standard', 'other.ms-titleimage', 'other.ms-coverimage', 'other.ms-thumbimage-standard', 'other.ms-thumbimage'): if x in self.oeb.guide: href = self.oeb.guide[x].href item = self.oeb.manifest.hrefs[href] covers.append([ self.oeb.guide[x], len(item.data)]) continue covers.sort(cmp = (lambda x, y: cmp(x[1], y[1])), reverse = True) if covers: ref = covers[0][0] if len(covers) > 1: self.log('Choosing %s:%s as the cover' % (ref.type, ref.href)) ref.type = 'cover' self.oeb.guide.refs['cover'] = ref for x in list(self.oeb.guide): href = urldefrag(self.oeb.guide[x].href)[0] if x.lower() not in ('cover', 'titlepage', 'masthead', 'toc', 'title-page', 'copyright-page', 'start'): self.oeb.guide.remove(x) continue