def get_kwargs(self, args):
<EOL>kwargs = {}<EOL>argspec = inspect.getargspec(self._func)<EOL>required = set(argspec.args[:-len(argspec.defaults)]<EOL>if argspec.defaults else argspec.args)<EOL>for arg_name in argspec.args:<EOL><INDENT>try:<EOL><INDENT>kwargs[arg_name] = getattr(args, arg_name)<EOL><DEDENT>except AttributeError:<EOL><INDENT>if arg_name in required:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>if argspec.keywords:<EOL><INDENT>for key, value in list(args.__dict__.items()):<EOL><INDENT>if key in kwargs:<EOL><INDENT>continue<EOL><DEDENT>kwargs[key] = value<EOL><DEDENT><DEDENT>return kwargs<EOL>
Given a Namespace object drawn from argparse, determines the
keyword arguments to pass to the underlying function.  Note
that, if the underlying function accepts all keyword
arguments, the dictionary returned will contain the entire
contents of the Namespace object.  Also note that an
AttributeError will be raised if any argument required by the
function is not set in the Namespace object.

:param args: A Namespace object from argparse.