Python yaml.parser() Examples
The following are 4
code examples of yaml.parser().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
yaml
, or try the search function
.
Example #1
Source File: cli.py From spectacles with MIT License | 6 votes |
def create_parser() -> argparse.ArgumentParser: """Creates the top-level argument parser. Returns: argparse.ArgumentParser: Top-level argument parser. """ parser = argparse.ArgumentParser(prog="spectacles") parser.add_argument("--version", action="version", version=__version__) subparser_action = parser.add_subparsers( title="Available sub-commands", dest="command" ) base_subparser = _build_base_subparser() _build_connect_subparser(subparser_action, base_subparser) _build_sql_subparser(subparser_action, base_subparser) _build_assert_subparser(subparser_action, base_subparser) _build_content_subparser(subparser_action, base_subparser) return parser
Example #2
Source File: cli.py From spectacles with MIT License | 5 votes |
def __call__(self, parser, namespace, values, option_string): """Populates argument defaults with values from the config file. Args: parser: Parent argparse parser that is calling the action. namespace: Object where parsed values will be set. values: Parsed values to be set to the namespace. option_string: Argument string, e.g. "--optional". """ config = self.parse_config(path=values) for dest, value in config.items(): for action in parser._actions: if dest == action.dest: """Required actions that are fulfilled by config are no longer required from the command line.""" action.required = False # Override default if not previously set by an environment variable. if not isinstance(action, EnvVarAction) or not os.environ.get( action.env_var ): setattr(namespace, dest, value) break else: raise SpectaclesException( name="invalid-config-file-param", title="Invalid configuration file parameter.", detail=f"Parameter '{dest}' in {values} is not valid.", ) parser.set_defaults(**config)
Example #3
Source File: cli.py From spectacles with MIT License | 5 votes |
def __call__(self, parser, namespace, values, option_string=None): """Sets the argument value to the namespace during parsing. Args: parser: Parent argparse parser that is calling the action. namespace: Object where parsed values will be set. values: Parsed values to be set to the namespace. option_string: Argument string, e.g. "--optional". """ setattr(namespace, self.dest, values)
Example #4
Source File: cli.py From spectacles with MIT License | 5 votes |
def __call__(self, parser, namespace, values, option_string=None): setattr(namespace, self.dest, True)