Source code for pysparkling.fileio.codec.gz

from __future__ import absolute_import

import gzip
from io import BytesIO
import logging

from .codec import Codec

log = logging.getLogger(__name__)

[docs]class Gz(Codec): """Implementation of :class:`.Codec` for gz compression.""" def compress(self, stream): compressed = BytesIO() with gzip.GzipFile(fileobj=compressed, mode='wb') as f: f.write( return compressed def decompress(self, stream): uncompressed = BytesIO() with gzip.GzipFile(fileobj=stream, mode='rb') as f: uncompressed.write( return uncompressed