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."""
[docs] def compress(self, stream): compressed = BytesIO() with gzip.GzipFile(fileobj=compressed, mode='wb') as f: f.write( return compressed
[docs] def decompress(self, stream): uncompressed = BytesIO() with gzip.GzipFile(fileobj=stream, mode='rb') as f: uncompressed.write( return uncompressed