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: object

Read 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

check_yaml_buffer(yaml_buffer: BufferedIOBase) BufferedIOBase

Perform some checks on passed yaml file.

Parameters:

yaml_buffer (BufferedIOBase) – bytes reader of the yaml file to check

Raises:
  • yaml.YAMLError – if YAML is not readable or invalid

  • Exception – unhandled error

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:
  • yaml.YAMLError – if YAML is not readable or invalid

  • Exception – unhandled error

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).

Returns:

a tuple with a boolean (True if the

running QDT version is compatible, False if it’s too old, None if the comparison could not be performed) and an explicit message (None if compatible).

Return type:

tuple[bool | None, str | None]

property metadata: dict | None

Get metadata from scenario.

Returns:

metadata if it does exist

scenario: dict | None = None
property settings: dict | None

Get scenario settings from scenario.

Returns:

settings section if it does exist

property steps: list[dict] | None

Get steps from scenario.

Returns:

list of scenario’s steps

validate_scenario() tuple[bool, list[str] | None]

Validate scenario file.

Returns:

True if scenario is valid, False otherwise and a report of validation errors (which is None if the scenario is valid).