Return a list of valid arguments.
767470
def getargs():
    
    parser = argparse.ArgumentParser(
        description='Python Disk Usage Calculator.')
    parser.add_argument("path", type=chkpath, nargs='?',
                        default=".", help="A valid path.")
    return parser.parse_args()
388677
def check_arguments(cls, passed):
        """"""
        defaults = list(cls.default_arguments().keys())
        template = ("Pass arg {argument:!r} in {cname:!r}, can be a typo? "
                    "Supported key arguments: {defaults}")
        fails = []
        for arg in passed:
            if arg not in defaults:
                warn(template.format(argument=arg,
                                     cname=cls.__name__,
                                     defaults=defaults))
                fails.append(arg)

        return any(fails)
664089
def default_arguments(cls):
        """"""
        func = cls.__init__
        args = func.__code__.co_varnames
        defaults = func.__defaults__
        index = -len(defaults)
        return {k: v for k, v in zip(args[index:], defaults)}
242351
def args_as_tuple(self):
        """"""
        result = ("currentdate", )
        result += (
            ":zone",
            self.extra_arguments["zone"].strip('"'),
            self.arguments["match-type"],
        )
        if self.arguments["match-type"] in [":count", ":value"]:
            result += (self.extra_arguments["match-type"].strip('"'), )
        result += (self.arguments["date-part"].strip('"'), )
        value = self.arguments["key-list"]
        if isinstance(value, list):
            # FIXME
            value = "[{}]".format(
                ",".join('"{}"'.format(item) for item in value))
        if value.startswith("["):
            result = result + tuple(tools.to_list(value))
        else:
            result = result + (value.strip('"'),)
        return result
678424
def validate_args(**args):
	
	if not args['query']:
		print("\nMissing required query argument.")
		sys.exit()

	for key in DEFAULTS:
		if key not in args:
			args[key] = DEFAULTS[key]

	return args
966425
def toArgs(self):
        """"""
        # FIXME - undocumented exception
        post_args = self.toPostArgs()
        kvargs = {}
        for k, v in post_args.items():
            if not k.startswith('openid.'):
                raise ValueError(
                    'This message can only be encoded as a POST, because it '
                    'contains arguments that are not prefixed with "openid."')
            else:
                kvargs[k[7:]] = v

        return kvargs
123327
def _arg_to_str(arg):
    """"""
    if isinstance(arg, str):
        return _sugar(repr(arg))
    elif arg is Empty:
        return '\u2014'
    else:
        return _sugar(str(arg))
1153502
def _parse_args():
    """"""
    class HelpOnErrorArgParser(argparse.ArgumentParser):
        """Print help message as well when an error is raised."""
        def error(self, message):
            sys.stderr.write("Error: %s\n" % message)
            self.print_help()
            sys.exit(2)

    def validate(_file):
        """Validate if the given target argument is a valid file or a valid directory"""
        _file = abspath(_file)
        if not exists(_file):
            if not exists(dirname(_file)):
                # Argparse uses the ArgumentTypeError to give a rejection message like:
                # error: argument input: x does not exist
                raise argparse.ArgumentTypeError("{0} does not exist".format(_file))
        return _file

    def expand_cg_args(cg_args):
        """Separate clubbed flags in command line args for the generator.py

        Allows flags to be clubbed like, -ilt example.txt.
        """
        expanded = list()
        for item in cg_args:
            if len(item) < 3:
                # If at all a flag, must be single flag
                expanded.append(item)
                continue
            if item.startswith("-"):
                if not item.startswith("--"):
                    for flag in item[1:]:
                        expanded.append('-' + flag)
                    continue
            expanded.append(item)
        return expanded

    class AssignDefaultIgnore(argparse.Action):
        """If argument is specified but nothing provided, use pre-defined.

        nargs="*" doesn't allow const and default kwarg can't be used as we might not want to
        ignore as well.
        """
        def __call__(self, parser, args, values, option_string=None):
            if values is not None and not len(values):
                values = IGNORE_METHODS
            setattr(args, self.dest, values)

    try:
        indx = sys.argv.index('--')
        cg_args, sys.argv = sys.argv[1:indx], sys.argv[:1] + sys.argv[indx + 1:]
    except ValueError:
        cg_args = []

    cg_args = expand_cg_args(cg_args)  # allow -il type of usage
    parser = HelpOnErrorArgParser(description=DESCRIPTION)
    parser.add_argument(
        "-l", "--long", action='store_true', default=False,
        help="File reference of method in call graph is absolute, i.e. starts with ansible, "
             "otherwise just the basename if not __init__.py")
    parser.add_argument(
        "-t", "--target", nargs="?", type=validate, const=TARGET_FILE, default=TARGET_FILE,
        help="Filepath to write call graph, defaults to %(default)s")
    parser.add_argument(
        "-i", "--ignore", nargs='*', action=AssignDefaultIgnore,
        help="Methods to ignore while generating call graph")
    # TODO: Aloow classes that can be intercepted
    parser.usage = \
        parser.format_usage()[len("usage: "):].rstrip() + " -- <ansible-playbook options>\n"
    cg_args = parser.parse_args(cg_args)

    if not len(sys.argv[1:]):
        parser.print_help()
        sys.exit(2)

    return cg_args
754313
def path_args(self):
        """"""
        self._path_args = []
        path = self.path
        path_args = list(filter(None, path.split('/')))
        return path_args
287209
def extract_kwargs(args, exp_keys, exp_elems):
    """"""
    arg_dict = {}    # For arguments that have values
    arg_set = set()  # For arguments that are True or False (present in set if True)
    for key, val in args.items():
        if exp_keys is not None and key in exp_keys and val:
            arg_dict[key] = val
        elif exp_elems is not None and key in exp_elems and val:
            arg_set.add(key)
    return {'dict':arg_dict, 'set':arg_set}
1364428
def _format_function_arguments(self, opts):
        """"""
        params = [self.Parameters[x] for x in opts]
        return ', '.join(filter(None, map(str, params)))
156311
def _fetch_arguments(handler, method):
    """"""

    if method.__name__ == 'get':
        arguments = {}
        for key, value in six.iteritems(handler.request.arguments):
            # Tornado supports comma-separated lists of values in
            # parameters. We're undoing that here, and if a list
            # is expected the _validate method can handle it.
            if isinstance(value, list):
                arguments[key] = ','.join(value)
            else:
                arguments[key] = value
    else:  # post, put, patch, delete?
        arguments = handler.get_post_arguments()

    return arguments
1128164
def get_kwargs(self):
        """"""
        return {k: v for k, v in vars(self).items() if k not in self._ignored}
606044
def _eval_kwargs(self):
        """"""
        evaled_kwargs = {}
        for k, v in self.p.kwargs.items():
            if util.is_param_method(v):
                v = v()
            evaled_kwargs[k] = v
        return evaled_kwargs
323990
def get_docargs(self, args=None, prt=None, **kws):
        """"""
        args_user = sys.argv[1:] if args is None else args
        arg_kws = self._get_docargs(args_user, prt)
        if 'intvals' in kws:
            self._set_intvals(arg_kws, kws['intvals'])
        return arg_kws
376377
def _get_args(self, kwargs):
        '''
        
        '''
        _args = list()
        _kwargs = salt.utils.args.clean_kwargs(**kwargs)

        return _args, _kwargs
1025511
def _parse_args(arg):
    '''
    
    '''
    yaml_args = salt.utils.args.yamlify_arg(arg)

    if yaml_args is None:
        return []
    elif not isinstance(yaml_args, list):
        return [yaml_args]
    else:
        return yaml_args