Reads the next uncompressed data from the gzip stream.

    Args:
      file_object (FileIO): file object that contains the compressed stream.

    Returns:
      bytes: next uncompressed data from the compressed stream.
506439
def Read(self, file_object):
    
    file_object.seek(self.last_read, os.SEEK_SET)
    read_data = file_object.read(self._MAXIMUM_READ_SIZE)
    self.last_read = file_object.get_offset()
    compressed_data = b''.join([self._compressed_data, read_data])
    decompressed, extra_compressed = self._decompressor.Decompress(
        compressed_data)
    self._compressed_data = extra_compressed
    self.uncompressed_offset += len(decompressed)
    return decompressed
759425
def read(fileobj, version=None):
    
    magic = fileobj.read(5)
    if magic[:4] != b"TZif":
        raise ValueError("not a zoneinfo file")
    if version is None:
        version = int(magic[4:]) if magic[4] else 0
    fileobj.seek(20)
    # Read the counts:
    # [0] - The number of UT/local indicators stored in the file.
    # [1] - The number of standard/wall indicators stored in the file.
    # [2] - The number of leap seconds for which data entries are stored
    #       in the file.
    # [3] - The number of transition times for which data entries are
    #       stored in the file.
    # [4] - The number of local time types for which data entries are
    #       stored in the file (must not be zero).
    # [5] - The number of characters of time zone abbreviation strings
    #  stored in the file.

    (ttisgmtcnt, ttisstdcnt, leapcnt,
     timecnt, typecnt, charcnt) = _read_counts(fileobj)
    if version >= 2:
        # Skip to the counts in the second header.
        data_size = (5 * timecnt +
                     6 * typecnt +
                     charcnt +
                     8 * leapcnt +
                     ttisstdcnt +
                     ttisgmtcnt)
        fileobj.seek(data_size + 20, os.SEEK_CUR)
        # Re-read the counts.
        (ttisgmtcnt, ttisstdcnt, leapcnt,
         timecnt, typecnt, charcnt) = _read_counts(fileobj)
        ttfmt = 'q'
    else:
        ttfmt = 'i'

    times = array(ttfmt)
    times.fromfile(fileobj, timecnt)
    if sys.byteorder != 'big':
        times.byteswap()

    type_indices = array('B')
    type_indices.fromfile(fileobj, timecnt)

    # Read local time types.
    type_infos = []
    for i in range(typecnt):
        type_infos.append(struct.unpack(">iBB", fileobj.read(6)))

    abbrs = fileobj.read(charcnt)

    if version > 0:
        # Skip to POSIX TZ string
        fileobj.seek(12 * leapcnt + ttisstdcnt + ttisgmtcnt, os.SEEK_CUR)
        posix_string = fileobj.read().strip().decode('ascii')
    else:
        posix_string = None

    # Convert type_infos
    for i, (gmtoff, isdst, abbrind) in enumerate(type_infos):
        abbr = abbrs[abbrind:abbrs.find(0, abbrind)].decode()
        type_infos[i] = (gmtoff, isdst, abbr)

    return TZFileData(version, type_infos, times, type_indices, posix_string)
725083
def unzip_file_if_necessary(self, source_file):
        
        if source_file.endswith(".gz"):
            self.print_message("Decompressing '%s'" % source_file)
            subprocess.check_call(["gunzip", "--force", source_file])
            source_file = source_file[:-len(".gz")]
        return source_file
1369643
def compute_gzip_md5(file_name):
    
    md5 = hashlib.md5()
    file_obj = gzip.open(file_name, 'rb')
    for chunk in iter(lambda: file_obj.read(8192), ''):
        md5.update(chunk)

    file_obj.close()
    return md5.hexdigest()
1364172
def _read_fd(file_descr):
        
        try:
            line = os.read(file_descr, 1024 * 1024)
        except OSError:
            stream_desc = NonBlockingStreamReader._get_sd(file_descr)
            if stream_desc is not None:
                stream_desc.has_error = True
                if stream_desc.callback is not None:
                    stream_desc.callback()
            return 0

        if line:
            stream_desc = NonBlockingStreamReader._get_sd(file_descr)
            if stream_desc is None:
                return 0 # Process closing

            if IS_PYTHON3:
                try:
                    # @TODO: further develop for not ascii/unicode binary content
                    line = line.decode("ascii")
                except UnicodeDecodeError:
                    line = repr(line)
            stream_desc.buf += line
            # Break lines
            split = stream_desc.buf.split(os.linesep)
            for line in split[:-1]:
                stream_desc.read_queue.appendleft(strip_escape(line.strip()))
                if stream_desc.callback is not None:
                    stream_desc.callback()
            # Store the remainded, its either '' if last char was '\n'
            # or remaining buffer before line end
            stream_desc.buf = split[-1]
            return len(line)
        return 0
795412
def Open(self, file_object):
    
    self._file_object = file_object
    self._regf_file.open_file_object(self._file_object)
    return True
594058
def get_filelikeobject(filename: str = None,
                       blob: bytes = None) -> BinaryIO:
    
    if not filename and not blob:
        raise ValueError("no filename and no blob")
    if filename and blob:
        raise ValueError("specify either filename or blob")
    if filename:
        return open(filename, 'rb')
    else:
        return io.BytesIO(blob)
775719
def _ReadEncodedData(self, read_size):
    
    encoded_data = self._file_object.read(read_size)

    read_count = len(encoded_data)

    self._encoded_data = b''.join([self._encoded_data, encoded_data])

    self._decoded_data, self._encoded_data = (
        self._decoder.Decode(self._encoded_data))

    self._decoded_data_size = len(self._decoded_data)

    return read_count
515494
def read_file(file):
	
	if hasattr(file, "read"):
		return file.read()
	if hasattr(file, "read_bytes"):
		return file.read_bytes()
	with open(file, "rb") as f:
		return f.read()
1314931
def readinto(self, b):
        
        if not self._readable:
            raise UnsupportedOperation('read')

        with self._seek_lock:
            # Gets seek
            seek = self._seek

            # Initializes queue
            queue = self._read_queue
            if seek == 0:
                # Starts initial preloading on first call
                self._preload_range()

            # Initializes read data buffer
            size = len(b)
            if size:
                # Preallocated buffer:
                # Use memory view to avoid copies
                b_view = memoryview(b)
                size_left = size
            else:
                # Dynamic buffer:
                # Can't avoid copy, read until EOF
                b_view = b
                size_left = -1
            b_end = 0

            # Starts reading
            buffer_size = self._buffer_size
            while size_left > 0 or size_left == -1:

                # Finds buffer position in queue and buffer seek
                start = seek % buffer_size
                queue_index = seek - start

                # Gets preloaded buffer
                try:
                    buffer = queue[queue_index]
                except KeyError:
                    # EOF
                    break

                # Get buffer from future
                with handle_os_exceptions():
                    try:
                        queue[queue_index] = buffer = buffer.result()

                    # Already evaluated
                    except AttributeError:
                        pass
                buffer_view = memoryview(buffer)
                data_size = len(buffer)

                # Checks if end of file reached
                if not data_size:
                    break

                # Gets theoretical range to copy
                if size_left != -1:
                    end = start + size_left
                else:
                    end = data_size - start

                # Checks for end of buffer
                if end >= data_size:
                    # Adjusts range to copy
                    end = data_size

                    # Removes consumed buffer from queue
                    del queue[queue_index]

                    # Append another buffer preload at end of queue
                    index = queue_index + buffer_size * self._max_buffers
                    if index < self._size:
                        queue[index] = self._workers.submit(
                            self._read_range, index, index + buffer_size)

                # Gets read size, updates seek and updates size left
                read_size = end - start
                if size_left != -1:
                    size_left -= read_size
                seek += read_size

                # Defines read buffer range
                b_start = b_end
                b_end = b_start + read_size

                # Copy data from preload buffer to read buffer
                b_view[b_start:b_end] = buffer_view[start:end]

            # Updates seek and sync raw
            self._seek = seek
            self._raw.seek(seek)

        # Returns read size
        return b_end
655077
def next(self):
        
        self._check("ra")
        if self.firstmember is not None:
            m = self.firstmember
            self.firstmember = None
            return m

        # Read the next block.
        self.fileobj.seek(self.offset)
        tarinfo = None
        while True:
            try:
                tarinfo = self.tarinfo.fromtarfile(self)
            except EOFHeaderError as e:
                if self.ignore_zeros:
                    self._dbg(2, "0x%X: %s" % (self.offset, e))
                    self.offset += BLOCKSIZE
                    continue
            except InvalidHeaderError as e:
                if self.ignore_zeros:
                    self._dbg(2, "0x%X: %s" % (self.offset, e))
                    self.offset += BLOCKSIZE
                    continue
                elif self.offset == 0:
                    raise ReadError(str(e))
            except EmptyHeaderError:
                if self.offset == 0:
                    raise ReadError("empty file")
            except TruncatedHeaderError as e:
                if self.offset == 0:
                    raise ReadError(str(e))
            except SubsequentHeaderError as e:
                raise ReadError(str(e))
            break

        if tarinfo is not None:
            self.members.append(tarinfo)
        else:
            self._loaded = True

        return tarinfo
1179455
def load(self, url, offset, length, no_record_parse=False):
        
        try:
            length = int(length)
        except:
            length = -1

        stream = self.loader.load(url, int(offset), length)
        decomp_type = 'gzip'

        # Create decompressing stream
        stream = DecompressingBufferedReader(stream=stream,
                                             decomp_type=decomp_type,
                                             block_size=self.block_size)

        return self.parse_record_stream(stream, no_record_parse=no_record_parse)
805070
def parse(cls, fileobj):
        

        try:
            length = cls._parse_desc_length_file(fileobj)
        except ValueError as e:
            raise DescriptorError(e)
        pos = fileobj.tell()
        instance = cls(fileobj, length)
        left = length - (fileobj.tell() - pos)
        if left < 0:
            raise DescriptorError("descriptor parsing read too much data")
        fileobj.seek(left, 1)
        return instance
1179903
def load_metadata(fileobj):
        
        with gzip.GzipFile(fileobj=fileobj, mode='r') as z:
            return json.loads(z.readline())
944246
def _py_read1(fileObj, maxBuffer):
    '''
        
    '''
    i = 0
    ret = []
    while i < maxBuffer:
        c = fileObj.read(1)
        if c == '':
            # Stream has been closed
            break
        i += 1
        ret.append(c)
        # Use a very low timeout so we only grab more data if it's immediately available.
        (readyToRead, junk1, junk2) = select.select([fileObj], [], [], .00001)
        if not readyToRead:
            break

    return ''.join(ret)
717705
def _ReadFileHeader(self, file_object):
    
    data_type_map = self._GetDataTypeMap('keychain_file_header')

    file_header, _ = self._ReadStructureFromFileObject(
        file_object, 0, data_type_map)

    if file_header.signature != self._FILE_SIGNATURE:
      raise errors.ParseError('Unsupported file signature.')

    if (file_header.major_format_version != self._MAJOR_VERSION or
        file_header.minor_format_version != self._MINOR_VERSION):
      raise errors.ParseError('Unsupported format version: {0:s}.{1:s}'.format(
          file_header.major_format_version, file_header.minor_format_version))

    return file_header
407741
def decompress(data):
    
    with GzipFile(fileobj=io.BytesIO(data)) as f:
        return f.read()