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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __version__ = '0.1'
  5. import string
  6. import Image
  7. import TiffImagePlugin
  8. from OleFileIO import *
  9.  
  10. def _accept(prefix):
  11.     return prefix[:8] == MAGIC
  12.  
  13.  
  14. class MicImageFile(TiffImagePlugin.TiffImageFile):
  15.     format = 'MIC'
  16.     format_description = 'Microsoft Image Composer'
  17.     
  18.     def _open(self):
  19.         
  20.         try:
  21.             self.ole = OleFileIO(self.fp)
  22.         except IOError:
  23.             raise SyntaxError, 'not an MIC file; invalid OLE file'
  24.  
  25.         self.images = []
  26.         for file in self.ole.listdir():
  27.             if file[1:] and file[0][-4:] == '.ACI' and file[1] == 'Image':
  28.                 self.images.append(file)
  29.                 continue
  30.         
  31.         if not self.images:
  32.             raise SyntaxError, 'not an MIC file; no image entries'
  33.         self.images
  34.         self._MicImageFile__fp = self.fp
  35.         self.frame = 0
  36.         if len(self.images) > 1:
  37.             self.category = Image.CONTAINER
  38.         
  39.         self.seek(0)
  40.  
  41.     
  42.     def seek(self, frame):
  43.         
  44.         try:
  45.             filename = self.images[frame]
  46.         except IndexError:
  47.             raise EOFError, 'no such frame'
  48.  
  49.         self.fp = self.ole.openstream(filename)
  50.         TiffImagePlugin.TiffImageFile._open(self)
  51.         self.frame = frame
  52.  
  53.     
  54.     def tell(self):
  55.         return self.frame
  56.  
  57.  
  58. Image.register_open('MIC', MicImageFile, _accept)
  59. Image.register_extension('MIC', '.mic')
  60.