Iterate over the chunks of the file according to their length prefixes.
        yields: index <int>, encrypted chunks without length prefixes <bytes>, lastchunk <bool>
977281
def iter_chunks(self, start_count=0):
        
        ciphertext = self.chunks_block
        chunknum = start_count
        idx = 0
        lastchunk = False
        while idx < len(ciphertext):
            plainlen = int.from_bytes(ciphertext[idx: idx+4], 'little')
            chunklen = plainlen + 16
            if idx + 4 + chunklen == len(ciphertext):
                lastchunk = True
            elif idx + chunklen > len(ciphertext):
                raise ValueError("Bad ciphertext; when reading chunks, hit EOF early")
            yield chunknum, ciphertext[idx + 4 : idx + 4 + chunklen], lastchunk
            idx += chunklen + 4
            chunknum += 1
1151003
def _chunks(iterable, n):
    
    iterable = iter(iterable)
    while True:
        # store one line in memory,
        # chain it to an iterator on the rest of the chunk
        yield chain([next(iterable)], islice(iterable, n-1))
1150932
def get_starting_chunk(filename, length=1024):
    
    # Ensure we open the file in binary mode
    with open(filename, 'rb') as f:
        chunk = f.read(length)
        return chunk
940490
def chunks_generator(iterable, count_items_in_chunk):
    
    iterator = iter(iterable)
    for first in iterator:  # stops when iterator is depleted
        def chunk():  # construct generator for next chunk
            yield first  # yield element from for loop
            for more in islice(iterator, count_items_in_chunk - 1):
                yield more  # yield more elements from the iterator

        yield chunk()
784233
async def iter_chunks(self, chunk_size=_DEFAULT_CHUNK_SIZE):
        
        while True:
            current_chunk = await self.read(chunk_size)
            if current_chunk == b"":
                break
            await yield_(current_chunk)
764051
def read_index_iter(self):
        

        with fopen(self.vpk_path, 'rb') as f:
            f.seek(self.header_length)

            while True:
                if self.version > 0 and f.tell() > self.tree_length + self.header_length:
                    raise ValueError("Error parsing index (out of bounds)")

                ext = _read_cstring(f)
                if ext == '':
                    break

                while True:
                    path = _read_cstring(f)
                    if path == '':
                        break
                    if path != ' ':
                        path = os.path.join(path, '')
                    else:
                        path = ''

                    while True:
                        name = _read_cstring(f)
                        if name == '':
                            break

                        (crc32,
                         preload_length,
                         archive_index,
                         archive_offset,
                         file_length,
                         suffix,
                         ) = metadata = list(struct.unpack("IHHIIH", f.read(18)))

                        if suffix != 0xffff:
                            raise ValueError("Error while parsing index")

                        if archive_index == 0x7fff:
                            metadata[3] = self.header_length + self.tree_length + archive_offset

                        metadata = (f.read(preload_length),) + tuple(metadata[:-1])

                        yield path + name + '.' + ext, metadata
1187954
def _file_chunks(self, data, chunk_size):
        
        for i in xrange(0, len(data), chunk_size):
            yield self.compressor(data[i:i+chunk_size])
1223618
def chunks_of(max_chunk_size, list_to_chunk):
    
    for i in range(0, len(list_to_chunk), max_chunk_size):
        yield list_to_chunk[i:i + max_chunk_size]
548369
def chunk(iterable, chunk_size=20):
    """"""
    items = []
    for value in iterable:
        items.append(value)
        if len(items) == chunk_size:
            yield items
            items = []
    if items:
        yield items
963733
def iter_chunked(self, n: int) -> AsyncStreamIterator[bytes]:
        
        return AsyncStreamIterator(lambda: self.read(n))
877398
def _slice_generator(self, index):
        """"""
        start, stop, step = index.indices(len(self))
        for i in range(start, stop, step):
            yield self.get_blob(i)
618221
def chunks(data, chunk_size):
    
    for i in xrange(0, len(data), chunk_size):
        yield data[i:i+chunk_size]
1284491
def fileChunkIter(file_object, file_chunk_size=65536):
    
    while True:
        chunk = file_object.read(file_chunk_size)
        if chunk:
            yield chunk
        else:
            break
678934
def _listChunks(self):
        
        chunks = []
        for fileName in os.listdir(self.dataDir):
            index = ChunkedFileStore._fileNameToChunkIndex(fileName)
            if index is not None:
                chunks.append(index)
        return sorted(chunks)
1185741
def chunks(self, size=32, alignment=1):
        

        if (size % alignment) != 0:
            raise Error(
                'size {} is not a multiple of alignment {}'.format(
                    size,
                    alignment))

        for segment in self:
            for chunk in segment.chunks(size, alignment):
                yield chunk
828095
def chunk(seq, n):
    # http://stackoverflow.com/a/312464/190597 (Ned Batchelder)
    
    for i in range(0, len(seq), n):
        yield seq[i:i + n]
504609
def read_chunks(file, size=io.DEFAULT_BUFFER_SIZE):
    """"""
    while True:
        chunk = file.read(size)
        if not chunk:
            break
        yield chunk