import inspect
import collections


def _get_decorator_parameters(obj, locals_):
    """
    Get the parameters used during function decoration.

    Args:
        obj (callable): Decorator object
        locals (dict): The local variables from the decorator frame.
    """
    # Get the function siganture and parameters.
    signature = inspect.signature(obj)
    parameters = signature.parameters.values()

    # Determine the arguments passed to the decorator.
    keys = [p.name for p in parameters if p.default == inspect._empty]
    args = [locals_[key] for key in keys]

    # Determine keyword arguments passed to the decorator.
    keys = [p.name for p in parameters if p.default != inspect._empty]
    kwargs = collections.OrderedDict()
    for key in keys:
        kwargs[key] = locals_[key]

    return args, kwargs