

def validate_args(fn, *args, **kwargs):
    'Check that the supplied args are sufficient for calling a function.\n\n    >>> validate_args(lambda a: None)\n    Traceback (most recent call last):\n        ...\n    MissingArgs: Missing argument(s): a\n    >>> validate_args(lambda a, b, c, d: None, 0, c=1)\n    Traceback (most recent call last):\n        ...\n    MissingArgs: Missing argument(s): b, d\n\n    :param fn: the function to check\n    :param args: the positional arguments supplied\n    :param kwargs: the keyword arguments supplied\n    '
    argspec = inspect.getargspec(fn)
    num_defaults = len((argspec.defaults or []))
    required_args = argspec.args[:(len(argspec.args) - num_defaults)]

    def isbound(method):
        return (getattr(method, '__self__', None) is not None)
    if isbound(fn):
        required_args.pop(0)
    missing = [arg for arg in required_args if (arg not in kwargs)]
    missing = missing[len(args):]
    if missing:
        raise MissingArgs(missing)

dataset/ETHPy150Open openstack/python-ironicclient/ironicclient/common/cliutils.py validate_args/original