qgis_deployment_toolbelt.scenarios.scenario_reader module¶
Read and validate scenario files.
Author: Julien Moura (https://github.com/guts, Oslandia)
- class qgis_deployment_toolbelt.scenarios.scenario_reader.ScenarioReader(in_yaml: str | Path | BufferedIOBase)¶
Bases:
objectRead and validate scenario files.
- __init__(in_yaml: str | Path | BufferedIOBase)¶
Instanciajeting YAML scenario reader.
- Parameters:
in_yaml (str | Path | BufferedIOBase) – input YAML file. Can be a path (as str or pathlib.Path) or an opened file.
- Raises:
TypeError – unsupported input type
InvalidScenarioError – if the content is not valid YAML or the file is not UTF-8 encoded
- static _parse_yaml(stream: TextIO | BufferedIOBase, source: Path | str) Any¶
Parse a YAML stream, turning parsing errors into InvalidScenarioError.
- Parameters:
stream (TextIO | BufferedIOBase) – opened YAML file or bytes buffer
source (Path | str) – path or name of the scenario, for the message
- Raises:
InvalidScenarioError – on YAML syntax error or text decoding error. The original error is chained (__cause__).
- Returns:
parsed content. Its structure is checked by validate_scenario().
- Return type:
Any
- check_yaml_buffer(yaml_buffer: BufferedIOBase) BufferedIOBase¶
Perform some checks on passed yaml buffer.
- Parameters:
yaml_buffer (BufferedIOBase) – bytes reader of the yaml file to check
- Raises:
ValueError – if the buffer is closed or not readable
- Returns:
checked bytes object
- Return type:
BufferedIOBase
- check_yaml_file(yaml_path: str | Path) Path¶
Perform some checks on passed yaml file and load it as Path object.
- Parameters:
yaml_path (str | Path) – path to the yaml file to check
- Raises:
OSError – if the path does not exist, is not a file or is not readable
ValueError – if the path is invalid
- Returns:
sanitized yaml path
- Return type:
Path
- is_qdt_version_compatible() tuple[bool | None, str | None]¶
Check if the running QDT version satisfies the scenario’s qdt_min_version metadata (if set).
- property settings: dict | None¶
Get scenario settings from scenario.
- Returns:
settings section if it does exist