Source code for

from __future__ import absolute_import

from io import BytesIO
import logging
import zipfile

from .codec import Codec

log = logging.getLogger(__name__)

[docs]class Zip(Codec): """Implementation of :class:`.Codec` for zip compression."""
[docs] def compress(self, stream): compressed = BytesIO() with zipfile.ZipFile(file=compressed, mode='w', allowZip64=True) as f: f.writestr('data', return compressed
[docs] def decompress(self, stream): uncompressed = BytesIO() with zipfile.ZipFile(file=stream, mode='r', allowZip64=True) as f: for f_name in f.namelist(): uncompressed.write( return uncompressed