def __init__(self, stream):
"""
Encapsulate the given stream in an unzipper.
"""
# Keep the stream
self.stream = stream
# Make a decompressor with the accept a gzip header flag.
# See <http://stackoverflow.com/a/22311297/402891>.
# Will get None'd out after we're done decompressing and it is flushed.
self.decompressor = zlib.decompressobj(zlib.MAX_WBITS + 16)
# Are we really compressed? This gets set to True if we successfully
# read the first block, and False if we failed to read the first block.
# If it's False, there's no need to try to decompress any more blocks.
self.header_read = None
# We need to do lines ourselves, so we need to keep a buffer
self.buffer = ""
# Track out throughput
self.compressed_bytes = 0
self.uncompressed_bytes = 0
评论列表
文章目录