Yield successive chunks of chunk_size from the iterable.
(iterator, chunk_size)
| 9 | |
| 10 | |
| 11 | def chunkify(iterator, chunk_size): |
| 12 | """Yield successive chunks of chunk_size from the iterable.""" |
| 13 | if isinstance(iterator, List): |
| 14 | iterator = iter(iterator) |
| 15 | for first in iterator: # Take the first element from the iterator |
| 16 | yield [first] + list(islice(iterator, chunk_size - 1)) |
| 17 | |
| 18 | |
| 19 | def create_file_hash(path_or_stream: Union[BytesIO, Path]) -> str: |
no outgoing calls
no test coverage detected