An iterable that will yield chunks of data. Given a file-like object as the constructor, yield chunks of read operations from that object.
| 539 | |
| 540 | |
| 541 | class ChunkIter: |
| 542 | """ |
| 543 | An iterable that will yield chunks of data. Given a file-like object as the |
| 544 | constructor, yield chunks of read operations from that object. |
| 545 | """ |
| 546 | |
| 547 | def __init__(self, flo, chunk_size=64 * 1024): |
| 548 | self.flo = flo |
| 549 | self.chunk_size = chunk_size |
| 550 | |
| 551 | def __next__(self): |
| 552 | try: |
| 553 | data = self.flo.read(self.chunk_size) |
| 554 | except InputStreamExhausted: |
| 555 | raise StopIteration() |
| 556 | if data: |
| 557 | return data |
| 558 | else: |
| 559 | raise StopIteration() |
| 560 | |
| 561 | def __iter__(self): |
| 562 | return self |
| 563 | |
| 564 | |
| 565 | class InterBoundaryIter: |