Yield each readable chunk present in the region.
        Chunks that can not be read for whatever reason are silently skipped.
        This function returns a :class:`nbt.chunk.Chunk` instance.
508614
def iter_chunks_class(self):
        
        for m in self.get_metadata():
            try:
                yield self.chunkclass(self.get_chunk(m.x, m.z))
            except RegionFileFormatError:
                pass
1279493
def chunkify(iterable, chunksize):
    
    from .queryset import QuerySet
    if hasattr(iterable, '__getitem__') and not isinstance(iterable, QuerySet):
        # tuple, list. QuerySet has __getitem__ but that evaluates the entire query greedily. We don't want that here.
        for i in range(0, len(iterable), chunksize):
            yield iterable[i:i + chunksize]
    else:
        # generator, set, map, QuerySet
        chunk = []
        for i in iterable:
            chunk.append(i)
            if len(chunk) == chunksize:
                yield chunk
                chunk = []
        if chunk:
            yield chunk
618221
def chunks(data, chunk_size):
    
    for i in xrange(0, len(data), chunk_size):
        yield data[i:i+chunk_size]
494731
async def iter_lines(self, chunk_size=1024):
        
        pending = b''
        async for chunk in self.iter_chunks(chunk_size):
            lines = (pending + chunk).splitlines(True)
            for line in lines[:-1]:
                await yield_(line.splitlines()[0])
            pending = lines[-1]
        if pending:
            await yield_(pending.splitlines()[0])
1088284
def _iter_chunk_offsets(self):
        
        chunk_offset = 8
        while True:
            chunk_data_len = self._stream_rdr.read_long(chunk_offset)
            chunk_type = self._stream_rdr.read_str(4, chunk_offset, 4)
            data_offset = chunk_offset + 8
            yield chunk_type, data_offset
            if chunk_type == 'IEND':
                break
            # incr offset for chunk len long, chunk type, chunk data, and CRC
            chunk_offset += (4 + 4 + chunk_data_len + 4)
97714
def _chunk_iter(self):
        """"""
        for chunk_offset in self._chunk_offsets():
            yield self._download_chunk(chunk_offset=chunk_offset,
                                       chunk_size=self._chunk_size)
37628
def allocated_chunks(self):
        
        raise NotImplementedError("%s not implemented for %s" % (self.allocated_chunks.__func__.__name__,
                                                                 self.__class__.__name__))
120843
async def read_chunk(self, size: int=chunk_size) -> bytes:
        
        if self._at_eof:
            return b''
        if self._length:
            chunk = await self._read_chunk_from_length(size)
        else:
            chunk = await self._read_chunk_from_stream(size)

        self._read_bytes += len(chunk)
        if self._read_bytes == self._length:
            self._at_eof = True
        if self._at_eof:
            newline = await self._content.readline()
            assert newline == self._newline, \
                'reader did not read all the data or it is malformed'
        return chunk
1104534
def chunk(iterable, size):
    
    # TODO: only used in gui.mainwindow(deprecated)
    iterator = iter(iterable)
    while size:
        result = []
        try:
            for i in range(size):
                elem = next(iterator)
                result.append(elem)
            yield tuple(result)
        except StopIteration:
            if result:
                yield tuple(result)
            return
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]
547332
def iterate_chunks(file, chunk_size):
    
    chunk = file.read(chunk_size)
    while chunk:
        yield chunk
        chunk = file.read(chunk_size)
1029904
def piece_file(input_f, chunk_size):
        
        chunk = input_f.read(chunk_size)
        total_bytes = 0
        while chunk:
            yield chunk
            chunk = input_f.read(chunk_size)
            total_bytes += len(chunk)
554887
def chunks(iterable, size=1):
    """"""
    iterator = iter(iterable)

    for element in iterator:
        yield chain([element], islice(iterator, size - 1))
174133
def read_blocks(self, block_size=4096):
        
        while True:
            out = self.mf.read(block_size)
            if not out:
                break
            yield bytes(out)
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
963733
def iter_chunked(self, n: int) -> AsyncStreamIterator[bytes]:
        
        return AsyncStreamIterator(lambda: self.read(n))
436468
async def readchunk(self) -> Tuple[bytes, bool]:
        
        while True:
            if self._exception is not None:
                raise self._exception

            while self._http_chunk_splits:
                pos = self._http_chunk_splits.pop(0)
                if pos == self._cursor:
                    return (b"", True)
                if pos > self._cursor:
                    return (self._read_nowait(pos-self._cursor), True)
                internal_logger.warning('Skipping HTTP chunk end due to data '
                                        'consumption beyond chunk boundary')

            if self._buffer:
                return (self._read_nowait_chunk(-1), False)
                # return (self._read_nowait(-1), False)

            if self._eof:
                # Special case for signifying EOF.
                # (b'', True) is not a final return value actually.
                return (b'', False)

            await self._wait('readchunk')