def validate_kwargs(func, kwargs):
func_name = func.__name__<EOL>argspec = inspect.getargspec(func)<EOL>all_args = argspec.args[:]<EOL>defaults = list(argspec.defaults or [])<EOL>if inspect.ismethod(func) and all_args[:<NUM_LIT:1>] == ['<STR_LIT>']:<EOL><INDENT>all_args[:<NUM_LIT:1>] = []<EOL><DEDENT>if defaults:<EOL><INDENT>required = all_args[:-len(defaults)]<EOL><DEDENT>else:<EOL><INDENT>required = all_args[:]<EOL><DEDENT>trans = {<EOL>arg: arg.endswith('<STR_LIT:_>') and arg[:-<NUM_LIT:1>] or arg<EOL>for arg<EOL>in all_args<EOL>}<EOL>for key in list(kwargs):<EOL><INDENT>key_adj = '<STR_LIT>' % key<EOL>if key_adj in all_args:<EOL><INDENT>kwargs[key_adj] = kwargs.pop(key)<EOL><DEDENT><DEDENT>supplied = sorted(kwargs)<EOL>missing = [<EOL>trans.get(arg, arg) for arg in required<EOL>if arg not in supplied<EOL>]<EOL>if missing:<EOL><INDENT>raise MeteorError(<EOL><NUM_LIT>,<EOL>func.err,<EOL>'<STR_LIT>' % (<EOL>func_name,<EOL>'<STR_LIT:U+0020>'.join(missing),<EOL>),<EOL>)<EOL><DEDENT>extra = [<EOL>arg for arg in supplied<EOL>if arg not in all_args<EOL>]<EOL>if extra:<EOL><INDENT>raise MeteorError(<EOL><NUM_LIT>,<EOL>func.err,<EOL>'<STR_LIT>' % (func_name, '<STR_LIT:U+0020>'.join(extra)),<EOL>)<EOL><DEDENT>
Validate arguments to be supplied to func.