import gzip import zlib import io import struct import sys import tarfile import json def decompress(data): """Decompress a gzip compressed string in one shot. Return the list of decompressed sections. """ while True: fp = io.BytesIO(data) if gzip._read_gzip_header(fp) is None: return # Use a zlib raw deflate compressor do = zlib.decompressobj(wbits=-zlib.MAX_WBITS) # Read all the data except the header decompressed = do.decompress(data[fp.tell():]) if not do.eof or len(do.unused_data) < 8: raise EOFError("Compressed file ended before the end-of-stream " "marker was reached") crc, length = struct.unpack("