From 4a23f48c24a76739e42e153ad5058f42fe332018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Tue, 26 Nov 2024 00:14:15 -0500 Subject: [PATCH 1/2] [pre-commit] Upgrade autoflake so that we get rid of its distutils dependency (package removed in Python 3.12, and deprecated in Python 3.10) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 429f5404b..12461ea94 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: # Remove unused imports/variables - repo: https://github.com/myint/autoflake - rev: v1.4 + rev: v2.3.1 hooks: - id: autoflake args: From 1ccab153aece402dacb7e8dc42dd79a2ba539102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Tue, 26 Nov 2024 00:15:22 -0500 Subject: [PATCH 2/2] [toppingexporter] Use ili2db's --exportMetaConfig to get schema import parameters from a DB --- .../gui/topping_wizard/ili2dbsettings_page.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py b/QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py index c0a6eba93..f5ffe5e8a 100644 --- a/QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py +++ b/QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py @@ -16,9 +16,10 @@ * * ***************************************************************************/ """ +import tempfile from enum import IntEnum -from qgis.core import QgsMapLayer, QgsProject +from qgis.core import Qgis, QgsMapLayer, QgsMessageLog, QgsProject from qgis.PyQt.QtCore import QAbstractItemModel, QModelIndex, Qt from qgis.PyQt.QtWidgets import QHeaderView, QTableView, QWizardPage @@ -26,6 +27,7 @@ Ili2DbCommandConfiguration, ) from QgisModelBaker.libs.modelbaker.utils import db_utils +from QgisModelBaker.libs.modelbaker.utils.ili2db_utils import Ili2DbUtils from QgisModelBaker.libs.modelbaker.utils.qt_utils import make_file_selector from QgisModelBaker.utils import gui_utils @@ -288,14 +290,22 @@ def _refresh_combobox(self): def _schema_changed(self): configuration = self.schema_combobox.currentData() + parsed_from_file = False if configuration: - db_connector = db_utils.get_db_connector(configuration) - if db_connector: - self.topping_wizard.topping.metaconfig.ili2db_settings.parse_parameters_from_db( - db_connector + _, tmp_ini_file = tempfile.mkstemp(".ini") + + ili2db_utils = Ili2DbUtils() + ili2db_utils.log_on_error.connect(self._log_on_export_metagonfig_error) + res, msg = ili2db_utils.export_metaconfig(tmp_ini_file, configuration) + if res: + parsed_from_file = self.topping_wizard.topping.metaconfig.ili2db_settings.parse_parameters_from_ini_file( + tmp_ini_file ) - else: + if not parsed_from_file: self.topping_wizard.topping.metaconfig.ili2db_settings.parameters = {} self.parameters_model.refresh_model( self.topping_wizard.topping.metaconfig.ili2db_settings.parameters ) + + def _log_on_export_metagonfig_error(self, log): + QgsMessageLog.logMessage(log, self.tr("Export metaConfig"), Qgis.Critical)