From 016484e7dccfb49c4acdb7b56357c2f54de2314a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 08:07:16 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- profile_manager/gui/interface_handler.py | 5 ++- profile_manager/gui/mdl_profiles.py | 5 +-- profile_manager/profile_manager.py | 13 +++++--- profile_manager/profile_manager_dialog.py | 35 ++++++++++---------- profile_manager/profiles/profile_creator.py | 6 ++-- profile_manager/profiles/utils.py | 8 ++--- profile_manager/qdt_export/profile_export.py | 13 ++++---- 7 files changed, 44 insertions(+), 41 deletions(-) diff --git a/profile_manager/gui/interface_handler.py b/profile_manager/gui/interface_handler.py index 9ca2ade..934be6d 100644 --- a/profile_manager/gui/interface_handler.py +++ b/profile_manager/gui/interface_handler.py @@ -1,9 +1,8 @@ from pathlib import Path from qgis.core import Qgis, QgsApplication, QgsMessageLog -from qgis.PyQt.QtCore import Qt, QVariant -from qgis.PyQt.QtGui import QIcon -from qgis.PyQt.QtWidgets import QDialog, QListWidgetItem +from qgis.PyQt.QtCore import Qt +from qgis.PyQt.QtWidgets import QDialog from profile_manager.datasources.dataservices.datasource_provider import ( DATA_SOURCE_SEARCH_LOCATIONS, diff --git a/profile_manager/gui/mdl_profiles.py b/profile_manager/gui/mdl_profiles.py index fd09fda..13a43ea 100644 --- a/profile_manager/gui/mdl_profiles.py +++ b/profile_manager/gui/mdl_profiles.py @@ -1,7 +1,8 @@ from pathlib import Path -from qgis.PyQt.QtCore import QObject, Qt, QModelIndex + +from qgis.core import QgsApplication, QgsUserProfile, QgsUserProfileManager +from qgis.PyQt.QtCore import QModelIndex, QObject, Qt from qgis.PyQt.QtGui import QStandardItemModel -from qgis.core import QgsUserProfileManager, QgsUserProfile, QgsApplication from profile_manager.profiles.utils import qgis_profiles_path diff --git a/profile_manager/profile_manager.py b/profile_manager/profile_manager.py index 2898112..f461a29 100644 --- a/profile_manager/profile_manager.py +++ b/profile_manager/profile_manager.py @@ -27,7 +27,6 @@ from os import path from pathlib import Path from shutil import copytree -from sys import platform # PyQGIS from qgis.core import Qgis, QgsMessageLog, QgsUserProfileManager @@ -49,8 +48,8 @@ from profile_manager.gui.interface_handler import InterfaceHandler from profile_manager.profile_manager_dialog import ProfileManagerDialog from profile_manager.profiles.profile_action_handler import ProfileActionHandler +from profile_manager.profiles.utils import get_profile_qgis_ini_path, qgis_profiles_path from profile_manager.utils import adjust_to_operating_system, wait_cursor -from profile_manager.profiles.utils import qgis_profiles_path, get_profile_qgis_ini_path class ProfileManager: @@ -252,7 +251,7 @@ def run(self): def set_paths(self): """Sets various OS and profile dependent paths""" - self.qgis_profiles_path = str(qgis_profiles_path()) + self.qgis_profiles_path = str(qgis_profiles_path()) self.backup_path = adjust_to_operating_system( str(Path.home()) + "/QGIS Profile Manager Backup/" @@ -458,8 +457,12 @@ def get_profile_paths(self) -> tuple[str, str]: def get_ini_paths(self): """Gets path to current chosen source and target qgis.ini file""" ini_paths = { - "source": str(get_profile_qgis_ini_path(self.dlg.comboBoxNamesSource.currentText())), - "target": str(get_profile_qgis_ini_path(self.dlg.comboBoxNamesTarget.currentText())), + "source": str( + get_profile_qgis_ini_path(self.dlg.comboBoxNamesSource.currentText()) + ), + "target": str( + get_profile_qgis_ini_path(self.dlg.comboBoxNamesTarget.currentText()) + ), } return ini_paths diff --git a/profile_manager/profile_manager_dialog.py b/profile_manager/profile_manager_dialog.py index 317ca1d..afc68ae 100644 --- a/profile_manager/profile_manager_dialog.py +++ b/profile_manager/profile_manager_dialog.py @@ -32,7 +32,11 @@ # plugin from profile_manager.gui.mdl_profiles import ProfileListModel -from profile_manager.qdt_export.profile_export import export_profile_for_qdt, get_qdt_profile_infos_from_file, QDTProfileInfos +from profile_manager.qdt_export.profile_export import ( + QDTProfileInfos, + export_profile_for_qdt, + get_qdt_profile_infos_from_file, +) # This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer FORM_CLASS, _ = uic.loadUiType( @@ -71,7 +75,7 @@ def get_list_selection_profile_name(self) -> Optional[str]: if index.isValid(): return self.list_profiles.model().data(index, ProfileListModel.NAME_COL) return None - + def _qdt_export_dir_changed(self) -> None: """Update UI when QDT export dir is changed: - enabled/disable button @@ -82,11 +86,12 @@ def _qdt_export_dir_changed(self) -> None: self.export_qdt_button.setEnabled(True) profile_json = Path(export_dir) / "profile.json" if profile_json.exists(): - self._set_qdt_profile_infos(get_qdt_profile_infos_from_file(profile_json)) + self._set_qdt_profile_infos( + get_qdt_profile_infos_from_file(profile_json) + ) else: self.export_qdt_button.setEnabled(False) - def _get_qdt_profile_infos(self) -> QDTProfileInfos: """Get QDTProfileInfos from UI @@ -94,14 +99,14 @@ def _get_qdt_profile_infos(self) -> QDTProfileInfos: QDTProfileInfos: QDT Profile Information """ return QDTProfileInfos( - description=self.qdt_description_edit.toPlainText(), - email=self.qdt_email_edit.text(), - version=self.qdt_version_edit.text(), - qgis_min_version=self.qdt_qgis_min_version_edit.text(), - qgis_max_version=self.qdt_qgis_max_version_edit.text(), - ) - - def _set_qdt_profile_infos(self, qdt_profile_infos : QDTProfileInfos) -> None: + description=self.qdt_description_edit.toPlainText(), + email=self.qdt_email_edit.text(), + version=self.qdt_version_edit.text(), + qgis_min_version=self.qdt_qgis_min_version_edit.text(), + qgis_max_version=self.qdt_qgis_max_version_edit.text(), + ) + + def _set_qdt_profile_infos(self, qdt_profile_infos: QDTProfileInfos) -> None: """Set QDTProfileInfos in UI Args: @@ -128,9 +133,5 @@ def export_qdt_handler(self) -> None: QMessageBox.information( self, self.tr("QDT profile export"), - self.tr( - "QDT profile have been successfully exported." - ), + self.tr("QDT profile have been successfully exported."), ) - - diff --git a/profile_manager/profiles/profile_creator.py b/profile_manager/profiles/profile_creator.py index e1a53f6..5dfa3e6 100644 --- a/profile_manager/profiles/profile_creator.py +++ b/profile_manager/profiles/profile_creator.py @@ -28,8 +28,10 @@ def create_new_profile(self): assert profile_name != "" # should be forced by the GUI self.qgs_profile_manager.createUserProfile(profile_name) try: - if platform is 'darwin': - profile_path = self.qgis_path + "/" + profile_name + "/qgis.org/" + if platform == "darwin": + profile_path = ( + self.qgis_path + "/" + profile_name + "/qgis.org/" + ) else: profile_path = self.qgis_path + "/" + profile_name + "/QGIS/" diff --git a/profile_manager/profiles/utils.py b/profile_manager/profiles/utils.py index fc8bef2..f7928e5 100644 --- a/profile_manager/profiles/utils.py +++ b/profile_manager/profiles/utils.py @@ -1,15 +1,13 @@ +from configparser import NoSectionError, RawConfigParser from dataclasses import dataclass from pathlib import Path from sys import platform from typing import Any, Dict, List, Optional -from configparser import NoSectionError, RawConfigParser - +import pyplugin_installer from qgis.core import QgsUserProfileManager from qgis.utils import iface -import pyplugin_installer - def qgis_profiles_path() -> Path: """Get QGIS profiles paths from current QGIS application @@ -105,7 +103,7 @@ def get_installed_plugin_metadata( def get_plugin_info_from_qgis_manager( - plugin_slug_name: str, reload_manager : bool = False + plugin_slug_name: str, reload_manager: bool = False ) -> Optional[Dict[str, str]]: """Get plugin informations from QGIS plugin manager diff --git a/profile_manager/qdt_export/profile_export.py b/profile_manager/qdt_export/profile_export.py index 74c1f02..fc3f84c 100644 --- a/profile_manager/qdt_export/profile_export.py +++ b/profile_manager/qdt_export/profile_export.py @@ -1,19 +1,17 @@ -from dataclasses import dataclass import dataclasses +import json +from dataclasses import dataclass from pathlib import Path from shutil import copytree, rmtree from typing import Any, Dict -import json - import pyplugin_installer from profile_manager.profiles.utils import ( - qgis_profiles_path, get_profile_plugin_list_information, + qgis_profiles_path, ) - QDT_PROFILE_SCHEMA = "https://raw.githubusercontent.com/Guts/qgis-deployment-cli/main/docs/schemas/profile/qgis_profile.json" @@ -28,7 +26,7 @@ class QDTProfileInfos: qgis_max_version: str = "" -def get_qdt_profile_infos_from_file(profile_file : Path) -> QDTProfileInfos: +def get_qdt_profile_infos_from_file(profile_file: Path) -> QDTProfileInfos: """Get QDT Profile informations from a profile.json file File must exists @@ -38,7 +36,7 @@ def get_qdt_profile_infos_from_file(profile_file : Path) -> QDTProfileInfos: Returns: QDTProfileInfos: QDT Profile informations """ - with open(profile_file, 'r') as f: + with open(profile_file, "r") as f: qdt_profile_data = json.load(f) return QDTProfileInfos( description=qdt_profile_data.get("description", ""), @@ -48,6 +46,7 @@ def get_qdt_profile_infos_from_file(profile_file : Path) -> QDTProfileInfos: qgis_max_version=qdt_profile_data.get("qgisMaximumVersion", ""), ) + def qdt_profile_dict( profile_name: str, qdt_profile_infos: QDTProfileInfos,