Generator that returns the datastream content in chunks, so
        larger datastreams can be used without reading the entire
        contents into memory.
432730
def get_chunked_content(self, chunksize=4096):
        ''''''

        # get the datastream dissemination, but return the actual http response
        r = self.obj.api.getDatastreamDissemination(self.obj.pid, self.id,
            stream=True,  asOfDateTime=self.as_of_date)
        # read and yield the response in chunks
        for chunk in r.iter_content(chunksize):
            yield chunk
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
474507
def stream(self, chunk_size=64*1024):
        ''
        #return self.jfs.stream(url='%s?mode=bin' % self.path, chunk_size=chunk_size)
        return self.jfs.stream(url=self.path, params={'mode':'bin'}, chunk_size=chunk_size)
741119
def _make_chunk_iter(stream, limit, buffer_size):
    """"""
    if isinstance(stream, (bytes, bytearray, text_type)):
        raise TypeError('Passed a string or byte object instead of '
                        'true iterator or stream.')
    if not hasattr(stream, 'read'):
        for item in stream:
            if item:
                yield item
        return
    if not isinstance(stream, LimitedStream) and limit is not None:
        stream = LimitedStream(stream, limit)
    _read = stream.read
    while 1:
        item = _read(buffer_size)
        if not item:
            break
        yield item
1180232
def read_in_chunks(file_object, chunk_size=CHUNK_SIZE):
    """"""
    while True:
        data = file_object.read(chunk_size)
        if not data:
            break
        yield data
267755
def http_stream(url, chunk=4096):
    
    ret = requests.get(url, stream=True)
    ret.raise_for_status()
    for data in ret.iter_content(chunk):
        yield data
308957
def download_yield_bytes(url, chunk_size=1024 * 1024 * 10):
    
    response = requests.get(url, stream=True)
    # raise error if download was unsuccessful
    response.raise_for_status()

    total_length = response.headers.get('content-length')
    if total_length is not None:
        total_length = float(total_length)
        length_str = "{0:.2f}Mb ".format(total_length / (1024 * 1024))
    else:
        length_str = ""

    print("Yielding {0:s} {1:s}".format(url, length_str))
    for chunk in response.iter_content(chunk_size=chunk_size):
        yield chunk
    response.close()
511662
def iterchunks(data, chunksize):
    
    offt = 0
    while offt < len(data):
        yield data[offt:offt+chunksize]
        offt += chunksize
887405
def _GenerateChunk(self, length):
    """"""

    while 1:
      to_read = min(length, self.RECV_BLOCK_SIZE)
      if to_read == 0:
        return

      data = self.rfile.read(to_read)
      if not data:
        return

      yield data
      length -= len(data)
635830
def get_stream(data=None):
        
        if len(__mstreams_available__) == 0:
            if data:
                mstream = MemoryStream(data)
                mstream.seek(0)
            else:
                mstream = MemoryStream()
            __mstreams__.append(mstream)
            return mstream

        mstream = __mstreams_available__.pop()

        if data is not None and len(data):
            mstream.clean_up()
            mstream.write(data)

        mstream.seek(0)

        return mstream
822072
public InputStream getContents() {
        final byte[] copy;
        synchronized (this) {
            final int length = this.contents.length;
            copy = new byte[length];
            System.arraycopy(this.contents, 0, copy, 0, this.contents.length);
        }
        return new ByteArrayInputStream(copy);
    }
740414
def read_content(self):
        """"""
        buf = StringIO()
        data = self.read_content_chunk()
        while data:
            if buf.tell() + len(data) > self.aggregate.config["maxfilesizedownload"]:
                raise LinkCheckerError(_("File size too large"))
            buf.write(data)
            data = self.read_content_chunk()
        return buf.getvalue()
795731
private DataOutputStream getDataStream(int keyLength)
      throws IOException {
    // Resize array if necessary
    if (dataStreams.length <= keyLength) {
      dataStreams = Arrays.copyOf(dataStreams, keyLength + 1);
      dataFiles = Arrays.copyOf(dataFiles, keyLength + 1);
    }

    DataOutputStream dos = dataStreams[keyLength];
    if (dos == null) {
      File file = new File(tempFolder, "data" + keyLength + ".dat");
      file.deleteOnExit();
      dataFiles[keyLength] = file;

      dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
      dataStreams[keyLength] = dos;

      // Write one byte so the zero offset is reserved
      dos.writeByte(0);
    }
    return dos;
  }
171728
def chunks(raw):
    """"""
    for i in range(0, len(raw), EVENT_SIZE):
        yield struct.unpack(EVENT_FORMAT, raw[i:i+EVENT_SIZE])
1062197
def chunks(data, n):
    """"""
    for i in range(0, len(data), n):
        yield data[i:i+n]
128037
def read_chunks(stream, block_size=2**10):
    
    while True:
        chunk = stream.read(block_size)
        if not chunk:
            break
        yield chunk
747387
def stream(self):
        '''
        '''
        chunk_a = None
        chunk_b = None
        chunk_a_index = 0
        chunk_b_index = 0
        search_start_index = 0

        while True:
            chunk_a = chunk_b
            chunk_a_index = chunk_b_index
            chunk_b = self._file.read(self._read_size)

            if chunk_a is None:
                continue

            chunk_b_index = chunk_a_index + len(chunk_a)

            if not chunk_a:
                break

            current_chunk = chunk_a + chunk_b[:self._overlap_size]

            offset_end = len(chunk_a) + self._overlap_size

            while True:
                offset_start = search_start_index - chunk_a_index
                match = self._pattern.search(
                    current_chunk, offset_start, offset_end)

                if not match:
                    unmatched_part = chunk_a[offset_start:]

                    if unmatched_part:
                        yield (None, unmatched_part)

                    search_start_index += len(unmatched_part)
                    break

                start_index, end_index = match.span(match.lastindex)

                unmatched_part = current_chunk[offset_start:start_index]

                if unmatched_part:
                    yield (None, unmatched_part)

                yield (match, match.group(match.lastindex))

                search_start_index += len(unmatched_part) + \
                    len(match.group(match.lastindex))