human
Write me a the Python code you requested given the following:
Complete the below
def handle_pagination_all(method):

    ''''Handles the "all" keyword argument, looping over the method page by
    page until the page is empty and then returning a list of items.
    Expects @param page="all, 1,2,.." etc'
    '''
assistant
#Here is the Python code you requested.
    def helper(page_results):
        '    Test    if    page    results    are    json,    or    a    generator.\n                                                We    want    to    keep    going    while    json    is    returned,\n                                                or    we    are    getting    non    empty    generators\n                                    '
        condition = page_results
        is_gen = inspect.isgeneratorfunction(page_results)
        is_gen |= inspect.isgenerator(page_results)
        if is_gen:
            condition = (peek(page_results) is not None)
        return condition
    @wraps(method)
    def wrapper(self, *args, **kwargs):
        kwargs = dict(kwargs)
        page = kwargs.pop('page', None)
        if (page == 'all'):
            kwargs['page'] = 1
            result = method(self, *args, **kwargs)
            condition = helper(result)
            while condition:
                (yield result)
                kwargs['page'] += 1
                try:
                    result = method(self, *args, **kwargs)
                    condition = helper(result)
                except:
                    break
        kwargs['page'] = page
        (yield method(self, *args, **kwargs))
    return wrapper