qgis_deployment_toolbelt.jobs.generic_job module

Base of QDT jobs.

Author: Julien Moura (https://github.com/guts)

class qgis_deployment_toolbelt.jobs.generic_job.GenericJob

Bases: object

Generic base for QDT jobs.

ID: str = ''
OPTIONS_SCHEMA: dict[str, dict[str, Any]] = {}
PROFILES_FOLDER_CACHE: dict[Path, tuple[QdtProfile, ...] | None] = {}
RULES_FILTER_CACHE: dict[tuple[Path, ...], tuple[list[QdtProfile], list[QdtProfile]]] = {}
__init__() None

Object instanciation.

classmethod clear_profiles_cache(folder_path: Path | None = None) None

Invalidate the profiles-folder scan cache to make subsequent jobs re-scan the directory instead of returning cached data.

Parameters:

folder_path (Path | None, optional) – specific cached folder to clear. If None, the entire cache is cleared. Defaults to None.

filter_profiles_folder(start_parent_folder: Path, cached: bool = True) tuple[QdtProfile, ...] | None

Parse a folder structure to filter on QGIS profiles folders.

Parameters:
  • start_parent_folder (Path) – root directory to scan for profile.json files.

  • cached (bool, optional) – return the previously computed result when available. Defaults to True.

Returns:

tuple of profiles objects matching criteria or

None if no profile folder found

Return type:

tuple[QdtProfile, …] | None

filter_profiles_on_rules(tup_qdt_profiles: tuple[QdtProfile, ...], cached: bool = True) tuple[list[QdtProfile], list[QdtProfile]]

Evaluate profile regarding to its deployment rules. Results are stored in the class RULES_FILTER_CACHE attribute.

Parameters:
  • tup_qdt_profiles (tuple[QdtProfile, ...]) – input tuple of QDT profiles

  • cached (bool, optional) – using previously computed value if not None. Defaults to True.

Returns:

tuple of profiles that matched and those which did not match their deployment rules

Return type:

tuple[QdtProfile], list[QdtProfile]]

get_matching_profile_from_name(li_profiles: list[QdtProfile], profile_name: str) QdtProfile | None

Get a profile from list of profiles using a profile’s name to match.

Parameters:
  • li_profiles (list[QdtProfile]) – list of profile to look into

  • profile_name (str) – profile name

Returns:

matching profile object

Return type:

QdtProfile

list_downloaded_profiles() tuple[QdtProfile, ...] | None
List downloaded QGIS profiles, i.e. a profile’s folder located into the QDT

working folder. Typically: ~/.cache/qgis-deployment-toolbelt/repositories/geotribu or %USERPROFILE%/.cache/qgis-deployment-toolbelt/repositories/geotribu).

Returns:

tuple of profiles objects or None if no profile

folder listed

Return type:

tuple[QdtProfile, …] | None

list_installed_profiles() tuple[QdtProfile, ...] | None
List installed QGIS profiles, i.e. a profile’s folder located into the QGIS

profiles path and so accessible to the end-user through the QGIS interface. Typically: ~/.local/share/QGIS/QGIS3/profiles/geotribu or %APPDATA%/QGIS/QGIS3/profiles/geotribu).

Returns:

tuple of profiles objects or None if no profile is

installed in QGIS3/profiles

Return type:

tuple[QdtProfile, …] | None

property os_config: OSConfiguration

Get current operating system configuration.

Returns:

object with settings regarding operating system and QGIS

Return type:

OSConfiguration

validate_options(options: dict[str, Any]) dict[str, Any]

Validate job options against OPTIONS_SCHEMA.

Parameters:

options (dict[str, Any]) – options to validate

Raises:
Returns:

unchanged when all checks pass

Return type:

dict[str, Any]