flake8 metabase

This commit is contained in:
2025-07-29 16:56:54 +02:00
parent fd5d516f14
commit d7267c0542
5 changed files with 384 additions and 425 deletions
+24 -27
View File
@@ -4,14 +4,13 @@ __email__ = "info@3liz.org"
from qgis.core import QgsApplication
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
from qgis.PyQt.QtCore import Qt, QUrl, QSettings
from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import QAction, QMessageBox
from qgis.PyQt.QtWidgets import QAction
from qgis.utils import iface
import qgis
#include <QSettings>
# include <QSettings>
'''
from pg_metadata.connection_manager import (
store_connections,
@@ -24,8 +23,9 @@ from pg_metadata.processing.provider import PgMetadataProvider
from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
'''
import os
from .about_form import MetabaseAboutDialog
from .tools.resources import (
plugin_path,
# plugin_path,
pyperclip,
resources_path,
maj_verif,
@@ -33,10 +33,8 @@ from .tools.resources import (
pyperclip()
from .dock import CenRa_Metabase
from .editor import Metabase_Editor
from .about_form import MetabaseAboutDialog
#from CenRa_Metabase.issues import CenRa_Issues
from qgis.PyQt.QtCore import *
# from CenRa_Metabase.issues import CenRa_Issues
class PgMetadata:
@@ -50,42 +48,42 @@ class PgMetadata:
self.dock_action = None
self.help_action = None
plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\')+1
end_find = plugin_dir.rfind('\\') + 1
global NAME
NAME = plugin_dir[end_find:]
maj_verif(NAME)
# Display About window on first use
version = qgis.utils.pluginMetadata('CenRa_METABASE','version')
version = qgis.utils.pluginMetadata('CenRa_METABASE', 'version')
s = QSettings()
versionUse = s.value("metadata/version", 1, type=str)
if str(versionUse) != str(version) :
if str(versionUse) != str(version):
s.setValue("metadata/version", str(version))
print(versionUse,version)
print(versionUse, version)
self.open_about_dialog()
# setup_logger('pg_metadata')
#locale, file_path = setup_translation(
# locale, file_path = setup_translation(
# folder=plugin_path("i18n"), file_pattern="CenRa_Metabase_{}.qm")
#if file_path:
# if file_path:
# self.translator = QTranslator()
# self.translator.load(file_path)
# noinspection PyCallByClass,PyArgumentList
# QCoreApplication.installTranslator(self.translator)
# noinspection PyPep8Naming
#def initProcessing(self):
#""" Add the QGIS Processing provider. """
#if not self.provider:
#self.provider = PgMetadataProvider()
#QgsApplication.processingRegistry().addProvider(self.provider)
# def initProcessing(self):
# """ Add the QGIS Processing provider. """
# if not self.provider:
# self.provider = PgMetadataProvider()
# QgsApplication.processingRegistry().addProvider(self.provider)
# noinspection PyPep8Naming
def initGui(self):
""" Build the plugin GUI. """
#self.initProcessing()
# self.initProcessing()
#self.check_invalid_connection_names()
# self.check_invalid_connection_names()
self.toolBar = iface.addToolBar("CenRa_Metabase")
self.toolBar.setObjectName("CenRa_Metabase")
@@ -100,8 +98,7 @@ class PgMetadata:
if not self.editor:
self.editor = Metabase_Editor()
self.editor_action = QAction(icon2, 'CenRa_Metabase',None)
self.editor_action = QAction(icon2, 'CenRa_Metabase', None)
self.toolBar.addAction(self.editor_action)
self.editor_action.triggered.connect(self.open_editor)
@@ -159,6 +156,7 @@ class PgMetadata:
"""
dialog = MetabaseAboutDialog(iface)
dialog.exec()
def open_help():
""" Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
@@ -178,9 +176,9 @@ class PgMetadata:
def unload(self):
""" Unload the plugin. """
#if self.editor:
#iface.removePluginMenu('CenRa_Metabase',self.editor_action)
#self.editor.removeToolBarIcon(self.editor_action)
# if self.editor:
# iface.removePluginMenu('CenRa_Metabase',self.editor_action)
# self.editor.removeToolBarIcon(self.editor_action)
if self.dock:
iface.removeDockWidget(self.dock)
@@ -202,7 +200,6 @@ class PgMetadata:
iface.pluginMenu().removeAction(self.dock_action)
del self.dock_action
@staticmethod
def run_tests(pattern='test_*.py', package=None):
"""Run the test inside QGIS."""