def takeexactly(iterable, size):
total = <NUM_LIT:0><EOL>for block in iterable:<EOL><INDENT>n = min(len(block), size - total)<EOL>block = block[:n]<EOL>if block:<EOL><INDENT>yield block<EOL><DEDENT>total += len(block)<EOL>if total >= size:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if total < size:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if total != size:  <EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>
Yield blocks from `iterable` until exactly len(size) have been returned.

    Args:
        iterable (iterable): Any iterable that yields sliceable objects that
                             have length.
        size (int): How much data to consume

    Yields:
        blocks from `iterable` such that
        sum(len(block) for block in takeexactly(iterable, size)) == size

    Raises:
        ValueError if there is less than `size` data in `iterable`