home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1003 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.2 KB  |  46 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. __license__ = 'GPL v3'
  6. __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
  7. __docformat__ = 'restructuredtext en'
  8.  
  9. class Clean(object):
  10.     
  11.     def __call__(self, oeb, opts):
  12.         urldefrag = urldefrag
  13.         import calibre.ebooks.oeb.base
  14.         self.oeb = oeb
  15.         self.log = oeb.log
  16.         self.opts = opts
  17.         if 'cover' not in self.oeb.guide:
  18.             covers = []
  19.             for x in ('other.ms-coverimage-standard', 'other.ms-titleimage-standard', 'other.ms-titleimage', 'other.ms-coverimage', 'other.ms-thumbimage-standard', 'other.ms-thumbimage'):
  20.                 if x in self.oeb.guide:
  21.                     href = self.oeb.guide[x].href
  22.                     item = self.oeb.manifest.hrefs[href]
  23.                     covers.append([
  24.                         self.oeb.guide[x],
  25.                         len(item.data)])
  26.                     continue
  27.             
  28.             covers.sort(cmp = (lambda x, y: cmp(x[1], y[1])), reverse = True)
  29.             if covers:
  30.                 ref = covers[0][0]
  31.                 if len(covers) > 1:
  32.                     self.log('Choosing %s:%s as the cover' % (ref.type, ref.href))
  33.                 
  34.                 ref.type = 'cover'
  35.                 self.oeb.guide.refs['cover'] = ref
  36.             
  37.         
  38.         for x in list(self.oeb.guide):
  39.             href = urldefrag(self.oeb.guide[x].href)[0]
  40.             if x.lower() not in ('cover', 'titlepage', 'masthead', 'toc', 'title-page', 'copyright-page', 'start'):
  41.                 self.oeb.guide.remove(x)
  42.                 continue
  43.         
  44.  
  45.  
  46.