utils/decorators.py
def allow_list(pos, name=None):
    """
    Decorator:
    Looks for the positional pos(int) or keyword name(str) argument and if
    the argument is a list calls the function once for each item

    This changes the function to always return void
    """
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if len(args) > pos:
                # args is normally an immutable tuple
                args = list(args)
                source = args
                key = pos
            elif name is not None and name in kwargs:
                source = kwargs
                key = name
            else:
                # The argument wasn't passed in .: original call
                func(*args, **kwargs)
                return

            # Make sure we'll loop through a list of one index
            if not isinstance(source[key], list):
                source[key] = [source[key]]
            for item in source[key]:
                source[key] = item
                func(*args, **kwargs)
        return wrapper
    return decorator

    Decorator:
    Looks for the positional pos(int) or keyword name(str) argument and if
    the argument is a list calls the function once for each item

    This changes the function to always return void
    
Looks for the positional pos(int) or keyword name(str) argument and if
the argument is a list calls the function once for each item

This changes the function to always return void
Looks for the positional pos ( int ) or keyword name ( str ) argument and if the argument is a list calls the function once for each item This changes the function to always return void
def allow_list(pos, name=None):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if len(args) > pos:
                args = list(args)
                source = args
                key = pos
            elif name is not None and name in kwargs:
                source = kwargs
                key = name
            else:
                func(*args, **kwargs)
                return
            if not isinstance(source[key], list):
                source[key] = [source[key]]
            for item in source[key]:
                source[key] = item
                func(*args, **kwargs)
        return wrapper
    return decorator
def allow_list ( pos , name = None ) : def decorator ( func ) : @ wraps ( func ) def wrapper ( * args , ** kwargs ) : if len ( args ) > pos : args = list ( args ) source = args key = pos elif name is not None and name in kwargs : source = kwargs key = name else : func ( * args , ** kwargs ) return if not isinstance ( source [ key ] , list ) : source [ key ] = [ source [ key ] ] for item in source [ key ] : source [ key ] = item func ( * args , ** kwargs ) return wrapper return decorator
Decorator:
Looks for the positional pos(int) or keyword name(str) argument and if
the argument is a list calls the function once for each item
Decorator : Looks for the positional pos ( int ) or keyword name ( str ) argument and if the argument is a list calls the function once for each item
"""
    Decorator:
    Looks for the positional pos(int) or keyword name(str) argument and if
    the argument is a list calls the function once for each item

    This changes the function to always return void
    """ # args is normally an immutable tuple # The argument wasn't passed in .: original call # Make sure we'll loop through a list of one index
pos
name