🟠Parsers

Parsers are used to process YAML config files into blueprints, one parser per object type.

All standard parsers are located in /parser/ directory.

Inheritance

All parsers are derived from AbstractParser class.

JSON schema

SnowDDL uses jsonschema Python library to validate YAML configs. JSON Schema for each object type is stored in the same file as parser for your convenience.

Methods

  • __init__(config: SnowDDLConfig, base_path: Path) Initialize parser with config and Path object containing path to config directory.

  • load_blueprints() Abstract method, it should be implemented by each parser class. Normally it reads YAML files, builds blueprints and adds blueprints to config.

  • parse_single_file(path: Path, json_schema: dict, callback: Callable = None) Accepts path to YAML file, JSON schema definition and optional callback function. Parses YAML file, validates it with provided JSON schema, process it using callback function. If any Exception is being raised inside callback function, it is treated as config validation error, "muted" and added to .errors property of config. If callback function was not defined, it returns processed YAML file as basic Python dict.

  • parse_schema_object_files(object_type: str, json_schema: dict, callback: Callable) Accepts name of object type (as string), JSON schema definition, mandatory callback function. Finds and parses all files of specified object type, validate each file with provided JSON schema, process each file with callback function. If any Exception is being raised inside callback function, it is treated as config validation error, "muted" and added to .errors property of config.

Last updated