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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import codecs
  5. import zlib
  6.  
  7. def zlib_encode(input, errors = 'strict'):
  8.     output = zlib.compress(input)
  9.     return (output, len(input))
  10.  
  11.  
  12. def zlib_decode(input, errors = 'strict'):
  13.     output = zlib.decompress(input)
  14.     return (output, len(input))
  15.  
  16.  
  17. class Codec(codecs.Codec):
  18.     
  19.     def encode(self, input, errors = 'strict'):
  20.         return zlib_encode(input, errors)
  21.  
  22.     
  23.     def decode(self, input, errors = 'strict'):
  24.         return zlib_decode(input, errors)
  25.  
  26.  
  27.  
  28. class IncrementalEncoder(codecs.IncrementalEncoder):
  29.     
  30.     def __init__(self, errors = 'strict'):
  31.         self.errors = errors
  32.         self.compressobj = zlib.compressobj()
  33.  
  34.     
  35.     def encode(self, input, final = False):
  36.         if final:
  37.             c = self.compressobj.compress(input)
  38.             return c + self.compressobj.flush()
  39.         return self.compressobj.compress(input)
  40.  
  41.     
  42.     def reset(self):
  43.         self.compressobj = zlib.compressobj()
  44.  
  45.  
  46.  
  47. class IncrementalDecoder(codecs.IncrementalDecoder):
  48.     
  49.     def __init__(self, errors = 'strict'):
  50.         self.errors = errors
  51.         self.decompressobj = zlib.decompressobj()
  52.  
  53.     
  54.     def decode(self, input, final = False):
  55.         if final:
  56.             c = self.decompressobj.decompress(input)
  57.             return c + self.decompressobj.flush()
  58.         return self.decompressobj.decompress(input)
  59.  
  60.     
  61.     def reset(self):
  62.         self.decompressobj = zlib.decompressobj()
  63.  
  64.  
  65.  
  66. class StreamWriter(Codec, codecs.StreamWriter):
  67.     pass
  68.  
  69.  
  70. class StreamReader(Codec, codecs.StreamReader):
  71.     pass
  72.  
  73.  
  74. def getregentry():
  75.     return codecs.CodecInfo(name = 'zlib', encode = zlib_encode, decode = zlib_decode, incrementalencoder = IncrementalEncoder, incrementaldecoder = IncrementalDecoder, streamreader = StreamReader, streamwriter = StreamWriter)
  76.  
  77.