qgis_deployment_toolbelt.constants module

Define toolbelt constant types and values.

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

class qgis_deployment_toolbelt.constants.OSConfiguration(name_python: str, names_alter: list[str], qgis_bin_exe_path: Path | None = None, qgis_profiles_path: Path | None = None, qgis_user_data_path: Path | None = None, qgis_version_major: Literal[3, 4] = 3, shortcut_extension: str | None = None, shortcut_forbidden_chars: tuple[str, ...] | None = None, shortcut_icon_default_path: str | None = None, shortcut_icon_extensions: tuple[str, ...] | None = None)

Bases: object

Settings related to QGIS and depending on operating system

__init__(name_python: str, names_alter: list[str], qgis_bin_exe_path: Path | None = None, qgis_profiles_path: Path | None = None, qgis_user_data_path: Path | None = None, qgis_version_major: Literal[3, 4] = 3, shortcut_extension: str | None = None, shortcut_forbidden_chars: tuple[str, ...] | None = None, shortcut_icon_default_path: str | None = None, shortcut_icon_extensions: tuple[str, ...] | None = None) → None
_is_envvar_qgis_exe_path_a_dict() → bool

Check if the QDT_QGIS_EXE_PATH environment variable is a dictionary.

Returns:

True if the environment variable is a dictionary, False otherwise.

Return type:

bool

_is_envvar_qgis_exe_path_a_string() → bool

Check if the QDT_QGIS_EXE_PATH environment variable is a string.

Returns:

True if the environment variable is a string, False otherwise.

Return type:

bool

classmethod from_opersys(operating_system_codename: str | None = None, qgis_version_major: Literal[3, 4] | None = None) → OSConfiguration
Create configuration object with defaults values from a operating system

code name.

Parameters:
  • operating_system_codename – operating system code name as specified in sys.platform. If None, fallback to current operating system. Defaults to None.

  • qgis_version_major – QGIS major version to target, which determines the profiles folder path. If None, it’s the QDT_QGIS_VERSION environment variable set by the qgis-installation-finder job. Defaults to None.

Returns:

OSConfiguration object with defaults settings

Return type:

Self

get_qgis_bin_path(use_fallback: bool = True) → bool | Path

Returns the QGIS path determined from QDT_QGIS_EXE_PATH environment variable, or result of which command or fallback to default value passed to the object.

Returns:

path to the QGIS bin/exe

Return type:

Path

get_qgis_profiles_path(qgis_version_major: Literal[3, 4] | None = None) → Path

Get the folder where QGIS stores the user’s profiles.

The QGIS_CUSTOM_CONFIG_PATH environment variable, used also by QGIS itself, takes precedence and is used as is.

Parameters:

qgis_version_major (SupportedQgisMajorVersion | None, optional) – QGIS major version to build the path for. If None, the one stored on the object is used. Defaults to None.

Returns:

path to the QGIS profiles folder.

Return type:

Path

name_python: str
names_alter: list[str]
qgis_bin_exe_path: Path | None = None
property qgis_profile_ini_filename: str

Filename of the QGIS settings file stored in a profile QGIS subfolder.

Returns:

name of the profile settings ini file.

Return type:

str

qgis_profiles_path: Path | None = None
qgis_user_data_path: Path | None = None
qgis_version_major: Literal[3, 4] = 3
shortcut_extension: str | None = None
shortcut_forbidden_chars: tuple[str, ...] | None = None
shortcut_icon_default_path: str | None = None
shortcut_icon_extensions: tuple[str, ...] | None = None
valid_shortcut_name(shortcut_name: str) → bool

Check if a given string is a valid shortcut name for the current operating system.

Parameters:

shortcut_name (str) – given shortcut name to check

Returns:

True if the given string can be used as shortcut name

Return type:

bool

qgis_deployment_toolbelt.constants.get_qdt_logs_folder() → Path
Get QDT logs folder. It uses the default path (a logs subfolder under the QDT

working folder) or the path defined in environment variable QDT_LOGS_DIR.

Returns:

path to the QDT logs folder.

Return type:

Path

qgis_deployment_toolbelt.constants.get_qdt_working_directory(specific_value: PathLike | None = None, identifier: str | None = None) → Path

Get QDT working directory.

Parameters:
  • specific_value (PathLike, optional) – a specific path to use. If set it’s expanded and returned. Defaults to None.

  • identifier (str, optional) – used to make the folder unique. Defaults to None.

Returns:

path to the QDT working directory

Return type:

Path

qgis_deployment_toolbelt.constants.get_qgis_version_major(qgis_version: str | int | None = None) → Literal[3, 4]

Determine the QGIS major version QDT has to work with .

Parameters:

qgis_version (str | int | None, optional) – QGIS version to read the major version from. Anything packaging can parse is accepted. If None, the QDT_QGIS_VERSION environment variable (set by the job qgis-installation-finder) is used. Defaults to None.

Returns:

QGIS major version supported by QDT. Fallback to

DEFAULT_QGIS_MAJOR_VERSION when it can’t be determined.

Return type:

SupportedQgisMajorVersion