def table_generator(tgen):
    """
    A low-level generator used to page through results from
    query and scan operations.  This is used by
    :class:`boto.dynamodb.layer2.TableGenerator` and is not intended
    to be used outside of that context.
    """
    response = True
    n = 0
    while response:
        if tgen.max_results and n == tgen.max_results:
            break
        if response is True:
            pass
        elif 'LastEvaluatedKey' in response:
            lek = response['LastEvaluatedKey']
            esk = tgen.table.layer2.dynamize_last_evaluated_key(lek)
            tgen.kwargs['exclusive_start_key'] = esk
        else:
            break
        response = tgen.callable(**tgen.kwargs)
        if 'ConsumedCapacityUnits' in response:
            tgen.consumed_units += response['ConsumedCapacityUnits']
        for item in response['Items']:
            if tgen.max_results and n == tgen.max_results:
                break
            yield tgen.item_class(tgen.table, attrs=item)
            n += 1
dataset/ETHPy150Open darcyliu/storyboard/boto/dynamodb/layer2.py/table_generator/original