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:
objectObject 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.
- 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:
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:
- 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:
- 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:
- 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:
- 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:
- is_qdt_version_compatible() tuple[bool | None, str | None]¶
Check if the running QDT version satisfies this profile’s qdtMinVersion attribute (if set).
- 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:
- 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:
- 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 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]