Given a decompression stream and chunks, yield chunks of
    decompressed data until the compression window ends.
766623
def _load_stream_py3(dc, chunks):
    
    while not dc.eof:
        res = dc.decompress(dc.unconsumed_tail + next(chunks))
        yield res
933925
def _decompress_into_buffer(self, out_buffer):
        
        zresult = lib.ZSTD_decompressStream(self._decompressor._dctx,
                                            out_buffer, self._in_buffer)

        if self._in_buffer.pos == self._in_buffer.size:
            self._in_buffer.src = ffi.NULL
            self._in_buffer.pos = 0
            self._in_buffer.size = 0
            self._source_buffer = None

            if not hasattr(self._source, 'read'):
                self._finished_input = True

        if lib.ZSTD_isError(zresult):
            raise ZstdError('zstd decompress error: %s' %
                            _zstd_error(zresult))

        # Emit data if there is data AND either:
        # a) output buffer is full (read amount is satisfied)
        # b) we're at end of a frame and not in frame spanning mode
        return (out_buffer.pos and
                (out_buffer.pos == out_buffer.size or
                 zresult == 0 and not self._read_across_frames))
1182675
def read_until_yieldable(self):
        """"""
        while not self.yieldable():
            read_content, read_position = _get_next_chunk(self.fp, self.read_position, self.chunk_size)
            self.add_to_buffer(read_content, read_position)
1078548
def chunks(data, size):
    
    for i in range(0, len(data), size):
        yield data[i:i + size]
1193956
def filechunk(f, chunksize):
    """"""
    while True:
        chunk = tuple(itertools.islice(f, chunksize))
        if not chunk:
            return
        yield np.loadtxt(iter(chunk), dtype=np.float64)
702380
def _decompress(self, fp):
        
        decompressor = zlib.decompressobj()
        if self.stream:
            return Proxy(decompressor.decompress, fp)
        else:
            out = io.BytesIO(decompressor.decompress(fp.read()))
            out.write(decompressor.flush())
            out.seek(0)
            return out
717261
def _chunks(l, n):
    
    for i in xrange(0, len(l), n):
        yield l[i:i+n]
331193
def chunks(self):
        

        while True:
            t, v = self.chunk()
            yield t, v
            if t == b'IEND':
                break
459293
def decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None):
    
    results = []
    while True:
        decomp = LZMADecompressor(format, memlimit, filters)
        try:
            res = decomp.decompress(data)
        except LZMAError:
            if results:
                break  # Leftover data is not a valid LZMA/XZ stream; ignore it.
            else:
                raise  # Error on the first iteration; bail out.
        results.append(res)
        if not decomp.eof:
            raise LZMAError("Compressed data ended before the "
                            "end-of-stream marker was reached")
        data = decomp.unused_data
        if not data:
            break
    return b"".join(results)
22466
async def _stream_helper(self, response, decode=False):
        """"""

        if decode:
            async for chunk in json_stream(
                    self._stream_helper(response, False)):
                yield chunk
        else:
            async with response.context as res:
                reader = res.content
                while True:
                    # this read call will block until we get a chunk
                    data = await reader.read(1)
                    if not data:
                        break
                    data += await reader.read(io.DEFAULT_BUFFER_SIZE)
                    yield data
552787
def decompress(self, data):
        
        chunks = []

        available_in = ffi.new("size_t *", len(data))
        in_buffer = ffi.new("uint8_t[]", data)
        next_in = ffi.new("uint8_t **", in_buffer)

        while True:
            # Allocate a buffer that's hopefully overlarge, but if it's not we
            # don't mind: we'll spin around again.
            buffer_size = 5 * len(data)
            available_out = ffi.new("size_t *", buffer_size)
            out_buffer = ffi.new("uint8_t[]", buffer_size)
            next_out = ffi.new("uint8_t **", out_buffer)

            rc = lib.BrotliDecoderDecompressStream(self._decoder,
                                                   available_in,
                                                   next_in,
                                                   available_out,
                                                   next_out,
                                                   ffi.NULL)

            # First, check for errors.
            if rc == lib.BROTLI_DECODER_RESULT_ERROR:
                error_code = lib.BrotliDecoderGetErrorCode(self._decoder)
                error_message = lib.BrotliDecoderErrorString(error_code)
                raise Error(
                    "Decompression error: %s" % ffi.string(error_message)
                )

            # Next, copy the result out.
            chunk = ffi.buffer(out_buffer, buffer_size - available_out[0])[:]
            chunks.append(chunk)

            if rc == lib.BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:
                assert available_in[0] == 0
                break
            elif rc == lib.BROTLI_DECODER_RESULT_SUCCESS:
                break
            else:
                # It's cool if we need more output, we just loop again.
                assert rc == lib.BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT

        return b''.join(chunks)
1066216
def _close_after_stream(self, response, chunk_size):
        """"""
        # Yield each chunk in the response body
        for chunk in response.iter_content(chunk_size=chunk_size):
            yield chunk
        # Once we're done streaming the body, ensure everything is closed.
        response.close()
618221
def chunks(data, chunk_size):
    
    for i in xrange(0, len(data), chunk_size):
        yield data[i:i+chunk_size]
426720
def _chunk(self, response, size=4096):
        
        method = response.headers.get("content-encoding")
        if method == "gzip":
            d = zlib.decompressobj(16+zlib.MAX_WBITS)
            b = response.read(size)
            while b:
                data = d.decompress(b)
                yield data
                b = response.read(size)
                del data
        else:
            while True:
                chunk = response.read(size)
                if not chunk: break
                yield chunk
289563
def finish(self, data=''):
        '''
        
        '''
        self.pending += data
        self.streaming = False
        for i in self:
            yield i
305436
public void compress(Stream<Path> paths) throws IOException
    {
        boolean first = true;
        Iterator<Path> it = paths.iterator();
        while (it.hasNext())
        {
            Path p = it.next();
            if (Files.isRegularFile(path))
            {
                setFilename(p.getFileName().toString());
                setLastModified(Files.getLastModifiedTime(p));
                if (!first)
                {
                    nextOutput();
                }
                first = false;
                OutputStream os = Channels.newOutputStream(this);
                Files.copy(p, os);
            }
            else
            {
                throw new IOException(p+" is not a regular file");
            }
        }
        close();
    }
375997
def _stream_helper(self, response, decode=False):
        """"""

        if response.raw._fp.chunked:
            if decode:
                for chunk in json_stream(self._stream_helper(response, False)):
                    yield chunk
            else:
                reader = response.raw
                while not reader.closed:
                    # this read call will block until we get a chunk
                    data = reader.read(1)
                    if not data:
                        break
                    if reader._fp.chunk_left:
                        data += reader.read(reader._fp.chunk_left)
                    yield data
        else:
            # Response isn't chunked, meaning we probably
            # encountered an error immediately
            yield self._result(response, json=decode)