qgis_deployment_toolbelt.profiles.qdt_profile module

QDT QGIS Profile object and related sugar.

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

class qgis_deployment_toolbelt.profiles.qdt_profile.QdtProfile(alias: str | None = None, author: str | None = None, description: str | None = None, email: str | None = None, folder: Path | None = None, icon: str | None = None, json_ref_path: Path | None = None, loaded_from_json: bool = False, name: str | None = None, plugins: list | None = None, qdt_min_version: str | None = None, qgis_maximum_version: str | None = None, qgis_minimum_version: str | None = None, rules: list[dict] | None = None, splash: str | None = None, version: str | None = None, **kwargs: Any)

Bases: object

Object definition for QGIS Profile handled by QDT.

ATTR_MAP = {'qdt_min_version': 'qdtMinVersion', 'qgis_maximum_version': 'qgisMaximumVersion', 'qgis_minimum_version': 'qgisMinimumVersion'}
__init__(alias: str | None = None, author: str | None = None, description: str | None = None, email: str | None = None, folder: Path | None = None, icon: str | None = None, json_ref_path: Path | None = None, loaded_from_json: bool = False, name: str | None = None, plugins: list | None = None, qdt_min_version: str | None = None, qgis_maximum_version: str | None = None, qgis_minimum_version: str | None = None, rules: list[dict] | None = None, splash: str | None = None, version: str | None = None, **kwargs: Any)

Initialize a QDT Profile object.

Parameters:
  • name (str) – name of the shortcut that will be created

  • author (str) – profile author name

property alias: str

Returns the profile’s alias.

Return str:

profile alias

property folder: Path | None

Returns the path to the folder where the profile is stored.

Returns:

profile folder path

Return type:

Path

classmethod from_json(profile_json_path: Path, profile_folder: Path | None = None) → QdtProfile

Load profile from a profile.json file.

Parameters:
  • profile_json_path (Path) – path to the profile json file

  • profile_folder (Path | None, optional) – path to the profile folder, defaults to None.

Returns:

QdtProfile object with attributes filled from JSON.

Return type:

QdtProfile

Example

QdtProfile = QdtProfile.from_json(Path(src_profile / "profile.json"))
print(profile.splash.resolve())
get_qgis_customization_ini_helper() → QgisIniHelper

Return the ini helper for the profile customization.

Returns:

Ini helper loaded with profile’s QGIS/QGISCUSTOMIZATION3.ini

Return type:

QgisIniHelper

get_qgis_ini_helper() → QgisIniHelper

Return the ini helper for the profile configuration.

Returns:

Ini helper loaded with profile’s QGIS/QGIS*.ini

Return type:

QgisIniHelper

has_qgis_customization_ini_file() → bool

Determine if a QGIS/QGISCUSTOMIZATION3.ini file exists in the profile folder.

Returns:

True if a QGIS/QGISCUSTOMIZATION3.ini file exists in the profile folder.

Return type:

bool

has_qgis_ini_file() → bool
Determine if a QGIS settings file (QGIS3.ini, QGIS4.ini…) exists in the

profile folder.

Returns:

True if a QGIS/QGIS*.ini file exists in the profile folder.

Return type:

bool

property icon: str | None

Returns the icon as specified into the original profile.json.

Return str:

profile icon value

property icon_path: Path

Returns the path to the profile’s icon into the profile folder.

Return Path:

profile icon path

property installed_profile: QdtProfile | None
Returns the installed profile object only if the corresponding profiles.json

exists.

Returns:

QdtProfile object if profile.json exists, else None

Return type:

QdtProfile | None

property is_loaded_from_json: bool

Tells if the profile has been loaded from a JSON file.

Return bool:

True if the profile has been loaded from a JSON file

is_older_than(version_to_compare: str | QdtProfile) → bool | None
Determine if the actual object version is older than the given version to

compare.

Parameters:
  • version_to_compare (Union[str, QdtProfile]) – given version to compare with object

  • version

Returns:

True if the given version is newer (more recent)

Return type:

bool

is_qdt_version_compatible() → tuple[bool | None, str | None]

Check if the running QDT version satisfies this profile’s qdtMinVersion attribute (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 json_ref_path: Path

Returns the path to the corresponding JSON path.

Return Path:

profile json_ref_path path

merge_to(dst: QdtProfile) → None

Merge QdtProfile to another profile.

Parameters:

dst (QdtProfile) – profile to merge to (i.e. destination profile, typically the installed one)

property name: str | None

Returns the profile’s name. If not set, the folder name is used.

Returns:

profile’s name

Return type:

str

property path_in_qgis: Path
Returns the path to the folder where the profile is stored in QGIS

(= installed).

Returns:

path to the installed (i.e. in QGIS) profile folder

Return type:

Path

property plugins: list[QgisPlugin]

Returns the plugins associated with the profile.

Returns:

list of plugins

Return type:

List[QgisPlugin]

property qdt_min_version: str | None

Returns the minimum QDT version required to deploy this profile.

Returns:

minimum QDT version or None if not set.

Return type:

str | None

property qgis_ini_filename: str

Name of the QGIS settings file expected by the targeted QGIS installation.

QGIS names it after its own major version: QGIS3.ini for QGIS 3, QGIS4.ini for QGIS 4.

Returns:

name of the profile settings ini file.

Return type:

str

property qgis_ini_filepath: Path

Path to the QGIS settings file to work with in the profile folder.

Returns:

path to the profile’s QGIS settings file, which may not exist yet.

Return type:

Path

property qgis_maximum_version: str | None

Maximum QGIS version the profile is compatible with.

Read from the qgisMaximumVersion key of the profile.json file.

Returns:

maximum QGIS version as string, None if the profile does not

declare any upper bound.

Return type:

str | None

property qgis_minimum_version: str | None

Minimum QGIS version the profile is compatible with.

Read from the qgisMinimumVersion key of the profile.json file.

Returns:

minimum QGIS version as string, None if the profile does not

declare any lower bound.

Return type:

str | None

property qgis_version_major: Literal[3, 4] | None

QGIS major version deduced from the profile folder’s parent directories.

Works only for installed profiles and for folder structure following the official QGIS one (‘QGIS/QGISX/profiles’), in case of custom profiles folder path.

Returns:

QGIS major version supported by QDT if it

can be deduced from the profile path, None otherwise.

Return type:

SupportedQgisMajorVersion | None

rename_qgis_ini_file_to_target_version() → Path | None
Rename the profile’s QGIS settings file to match the targeted QGIS major

version.

A profile authored for QGIS 3 ships a QGIS/QGIS3.ini file, which QGIS 4 silently ignores since it reads QGIS/QGIS4.ini. Renaming it keeps the settings shipped by the profile effective after an upgrade.

Returns:

path to the renamed file, None if nothing has been renamed.

Return type:

Path | None

property rules: list[dict] | None

Returns the rules associated with the profile.

Returns:

list of rules

Return type:

list[rules]

property splash: str | Path | None

Returns the profile splash image as path if can be resolved or as string.

Returns:

path to the profile splash image

Return type:

Union[str, Path]

status() → Literal['downloaded', 'installed', 'unknown']

Determine current profile status: downloaded (in QDT working folder), installed (in the QGIS profiles folder) or unknown.

Returns:

one of “downloaded”, “installed”, “unknown”

Return type:

str

property version: str | None

Returns the profile version as string.

Returns:

version

Return type:

str