Beispiel #1
0
 def compress(self, content):
     content = self._trans_type(content)
     if len(content) > self.min_length:
         try:
             return zlib.compress(content, self.preset)
         except zlib.error as exc:
             raise CompressError('Content can not be compressed.')
     return content
Beispiel #2
0
 def decompress(self, content):
     content = self._trans_type(content)
     try:
         return zlib.decompress(content)
     except zlib.error as exc:
         raise CompressError('Content can not be decompressed.')