home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_878 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  2.8 KB  |  73 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
  6. __docformat__ = 'restructuredtext en'
  7. from calibre.customize import Plugin
  8.  
  9. class InvalidEpub(ValueError):
  10.     pass
  11.  
  12.  
  13. class ParseError(ValueError):
  14.     
  15.     def __init__(self, name, desc):
  16.         self.name = name
  17.         self.desc = desc
  18.         ValueError.__init__(self, _('Failed to parse: %s with error: %s') % (name, desc))
  19.  
  20.  
  21.  
  22. class ePubFixer(Plugin):
  23.     supported_platforms = [
  24.         'windows',
  25.         'osx',
  26.         'linux']
  27.     author = 'Kovid Goyal'
  28.     type = _('ePub Fixer')
  29.     can_be_disabled = True
  30.     
  31.     def short_description(self):
  32.         raise NotImplementedError
  33.  
  34.     short_description = property(short_description)
  35.     
  36.     def long_description(self):
  37.         raise NotImplementedError
  38.  
  39.     long_description = property(long_description)
  40.     
  41.     def fix_name(self):
  42.         raise NotImplementedError
  43.  
  44.     fix_name = property(fix_name)
  45.     
  46.     def options(self):
  47.         return []
  48.  
  49.     options = property(options)
  50.     
  51.     def run(self, container, opts, log, fix = False):
  52.         raise NotImplementedError
  53.  
  54.     
  55.     def add_options_to_parser(self, parser):
  56.         parser.add_option('--' + self.fix_name.replace('_', '-'), help = self.long_description, action = 'store_true', default = False)
  57.         for option in self.options:
  58.             action = 'store'
  59.             if option[1] == 'bool':
  60.                 action = 'store_true'
  61.             
  62.             kwargs = {
  63.                 'action': action,
  64.                 'default': option[2],
  65.                 'help': option[3] }
  66.             if option[1] != 'bool':
  67.                 kwargs['type'] = option[1]
  68.             
  69.             parser.add_option('--' + option[0].replace('_', '-'), **kwargs)
  70.         
  71.  
  72.  
  73.