diff --git a/.gitignore b/.gitignore
index 9481646..a012f1f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,3 @@ __pycache__
i18n
.DS_Store
.tokens
-
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index bceadc2..25e7d03 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -56,4 +56,4 @@ repos:
ci:
autofix_prs: true
- autoupdate_schedule: quarterly
\ No newline at end of file
+ autoupdate_schedule: quarterly
diff --git a/.qgis-plugin-ci b/.qgis-plugin-ci
index 43cb4ca..c7266ae 100644
--- a/.qgis-plugin-ci
+++ b/.qgis-plugin-ci
@@ -1,3 +1,3 @@
plugin_path: geomapfish_locator
github_organization_slug: opengisch
-project_slug: qgis_geomapfish_locator
\ No newline at end of file
+project_slug: qgis_geomapfish_locator
diff --git a/README.md b/README.md
index 4d90af0..a93eb4f 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,6 @@ Validate and start searching in the locator bar at the bottom left of the applic
## Advanced configuration
-Each service will create its own locator filter. All the filters can be seen under the locator settings
+Each service will create its own locator filter. All the filters can be seen under the locator settings
(in `Settings` -> `Options` -> `Locator`) and can be configured from there, including the prefix configuration.
If you want to avoid typing the prefix of the filter (`gmf`), enable the filter by default.
diff --git a/geomapfish_locator/__init__.py b/geomapfish_locator/__init__.py
index 35e19bf..23c263e 100644
--- a/geomapfish_locator/__init__.py
+++ b/geomapfish_locator/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# -----------------------------------------------------------
#
# QGIS Geomapfish Locator Plugin
@@ -32,5 +31,8 @@ def classFactory(iface):
:type iface: QgsInterface
"""
#
- from geomapfish_locator.core.geomapfish_locator_plugin import GeomapfishLocatorPlugin
+ from geomapfish_locator.core.geomapfish_locator_plugin import (
+ GeomapfishLocatorPlugin,
+ )
+
return GeomapfishLocatorPlugin(iface)
diff --git a/geomapfish_locator/core/geomapfish_locator_plugin.py b/geomapfish_locator/core/geomapfish_locator_plugin.py
index dd2ddb7..26541a1 100644
--- a/geomapfish_locator/core/geomapfish_locator_plugin.py
+++ b/geomapfish_locator/core/geomapfish_locator_plugin.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
/***************************************************************************
@@ -17,19 +16,27 @@
***************************************************************************/
"""
-
import os
-from qgis.PyQt.QtCore import QCoreApplication, QLocale, QSettings, QTranslator, pyqtSlot, QObject
-from qgis.PyQt.QtWidgets import QAction, QMenu, QMessageBox
+
from qgis.core import NULL
from qgis.gui import QgisInterface
+from qgis.PyQt.QtCore import (
+ QCoreApplication,
+ QLocale,
+ QObject,
+ QSettings,
+ QTranslator,
+ pyqtSlot,
+)
+from qgis.PyQt.QtWidgets import QAction, QMenu, QMessageBox
+
from geomapfish_locator.core.locator_filter import GeomapfishLocatorFilter
from geomapfish_locator.core.old_version_import import old_version_import
-from geomapfish_locator.core.settings import Settings
from geomapfish_locator.core.service import Service
+from geomapfish_locator.core.settings import Settings
from geomapfish_locator.core.utils import info
-from geomapfish_locator.gui.geomapfish_settings_dialog import GeomapfishSettingsDialog
from geomapfish_locator.gui.filter_configuration_dialog import FilterConfigurationDialog
+from geomapfish_locator.gui.geomapfish_settings_dialog import GeomapfishSettingsDialog
DEBUG = True
@@ -43,15 +50,19 @@ def __init__(self, iface: QgisInterface):
self.iface = iface
self.locator_filters = []
self.settings = Settings()
- menu_action_new = QAction(QCoreApplication.translate('Geomapfish', 'Add new service'), self.iface.mainWindow())
+ menu_action_new = QAction(
+ QCoreApplication.translate("Geomapfish", "Add new service"), self.iface.mainWindow()
+ )
menu_action_new.triggered.connect(self.new_service)
self.iface.addPluginToMenu(self.plugin_name, menu_action_new)
- menu_action_settings = QAction(QCoreApplication.translate('Geomapfish', 'Settings'), self.iface.mainWindow())
+ menu_action_settings = QAction(
+ QCoreApplication.translate("Geomapfish", "Settings"), self.iface.mainWindow()
+ )
menu_action_settings.triggered.connect(self.show_settings)
self.iface.addPluginToMenu(self.plugin_name, menu_action_settings)
self.menu_entries = [menu_action_new, menu_action_settings]
- for definition in self.settings.value('services'):
+ for definition in self.settings.value("services"):
self.add_service(Service(definition))
import_service = old_version_import()
@@ -62,9 +73,9 @@ def __init__(self, iface: QgisInterface):
qgis_locale = QLocale(
str(QSettings().value("locale/userLocale")).replace(str(NULL), "en_CH")
)
- locale_path = os.path.join(os.path.dirname(__file__), 'i18n')
+ locale_path = os.path.join(os.path.dirname(__file__), "i18n")
self.translator = QTranslator()
- self.translator.load(qgis_locale, 'geomapfish_locator', '_', locale_path)
+ self.translator.load(qgis_locale, "geomapfish_locator", "_", locale_path)
QCoreApplication.installTranslator(self.translator)
def initGui(self):
@@ -72,10 +83,12 @@ def initGui(self):
def add_locator_menu_action(self, locator_filter: GeomapfishLocatorFilter):
menu = QMenu(locator_filter.service.name, self.iface.mainWindow())
- edit_action = menu.addAction(self.tr('edit'))
+ edit_action = menu.addAction(self.tr("edit"))
edit_action.triggered.connect(lambda _: locator_filter.openConfigWidget())
- remove_action = menu.addAction(self.tr('remove'))
- remove_action.triggered.connect(lambda _: GeomapfishLocatorPlugin.remove_service(self, locator_filter, menu))
+ remove_action = menu.addAction(self.tr("remove"))
+ remove_action.triggered.connect(
+ lambda _: GeomapfishLocatorPlugin.remove_service(self, locator_filter, menu)
+ )
self.iface.addPluginToMenu(self.plugin_name, menu.menuAction())
self.menu_entries.append(menu)
@@ -84,18 +97,18 @@ def new_service(self):
dlg = FilterConfigurationDialog(service)
if dlg.exec_():
if not dlg.service.is_valid():
- info("Service {}({}) is not valid".format(service.name, service.url))
+ info(f"Service {service.name}({service.url}) is not valid")
else:
self.add_service(dlg.service.clone())
def add_service(self, service):
if not service.is_valid():
- info("Service {}({}) is not valid".format(service.name, service.url))
+ info(f"Service {service.name}({service.url}) is not valid")
return
for locator_filter in self.locator_filters:
if service.name == locator_filter.service.name:
- service.name = QCoreApplication.translate('Geomapfish', '{service} copy'.format(service=service.name))
+ service.name = QCoreApplication.translate("Geomapfish", f"{service.name} copy")
locator_filter = GeomapfishLocatorFilter(service, self.iface)
locator_filter.changed.connect(self.filter_changed)
@@ -106,9 +119,12 @@ def add_service(self, service):
def remove_service(self, locator_filter, menu):
reply = QMessageBox.question(
- self.iface.mainWindow(), self.plugin_name,
- self.tr('Are you sure to remove service "{}"'.format(locator_filter.service.name)),
- QMessageBox.Yes, QMessageBox.No)
+ self.iface.mainWindow(),
+ self.plugin_name,
+ self.tr(f'Are you sure to remove service "{locator_filter.service.name}"'),
+ QMessageBox.Yes,
+ QMessageBox.No,
+ )
if reply == QMessageBox.Yes:
self.iface.removePluginMenu(self.plugin_name, menu.menuAction())
self.menu_entries.remove(menu)
@@ -119,7 +135,7 @@ def remove_service(self, locator_filter, menu):
def unload(self):
self.iface.invalidateLocatorResults()
for menu_entry in self.menu_entries:
- if type(menu_entry) == QAction:
+ if isinstance(menu_entry, QAction):
self.iface.removePluginMenu(self.plugin_name, menu_entry)
else:
self.iface.removePluginMenu(self.plugin_name, menu_entry.menuAction())
@@ -132,11 +148,11 @@ def save_services(self):
services = []
for locator_filter in self.locator_filters:
services.append(locator_filter.service.as_dict())
- self.settings.set_value('services', services)
+ self.settings.set_value("services", services)
def refresh_menu(self):
for menu_entry in self.menu_entries[1:]:
- if type(menu_entry) == QAction:
+ if isinstance(menu_entry, QAction):
self.iface.removePluginMenu(self.plugin_name, menu_entry)
else:
self.iface.removePluginMenu(self.plugin_name, menu_entry.menuAction())
diff --git a/geomapfish_locator/core/locator_filter.py b/geomapfish_locator/core/locator_filter.py
index 6ef2030..d805f81 100644
--- a/geomapfish_locator/core/locator_filter.py
+++ b/geomapfish_locator/core/locator_filter.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
/***************************************************************************
@@ -17,23 +16,38 @@
***************************************************************************/
"""
-
import json
import re
-from qgis.PyQt.QtCore import Qt
+from osgeo import ogr
+from qgis.core import (
+ Qgis,
+ QgsApplication,
+ QgsBlockingNetworkRequest,
+ QgsCoordinateReferenceSystem,
+ QgsGeometry,
+ QgsLocatorFilter,
+ QgsLocatorResult,
+ QgsMessageLog,
+ QgsReferencedRectangle,
+ QgsWkbTypes,
+)
+from qgis.gui import QgisInterface, QgsRubberBand
+from qgis.PyQt.QtCore import (
+ QByteArray,
+ Qt,
+ QTimer,
+ QUrl,
+ QUrlQuery,
+ pyqtSignal,
+ pyqtSlot,
+)
from qgis.PyQt.QtGui import QColor
-from qgis.PyQt.QtCore import QUrl, QUrlQuery, QTimer, pyqtSlot, pyqtSignal, QByteArray
from qgis.PyQt.QtNetwork import QNetworkRequest
-from qgis.core import Qgis, QgsMessageLog, QgsLocatorFilter, QgsLocatorResult, QgsApplication, \
- QgsCoordinateReferenceSystem, QgsGeometry, QgsWkbTypes, QgsBlockingNetworkRequest, QgsReferencedRectangle
-from qgis.gui import QgsRubberBand, QgisInterface
-from osgeo import ogr
-
from geomapfish_locator.core.service import Service
-from geomapfish_locator.core.utils import slugify, dbg_info
from geomapfish_locator.core.settings import Settings
+from geomapfish_locator.core.utils import dbg_info, slugify
from geomapfish_locator.gui.filter_configuration_dialog import FilterConfigurationDialog
DEBUG = True
@@ -45,7 +59,7 @@ class FilterNotConfigured:
class GeomapfishLocatorFilter(QgsLocatorFilter):
- USER_AGENT = b'Mozilla/5.0 QGIS GeoMapFish Locator Filter'
+ USER_AGENT = b"Mozilla/5.0 QGIS GeoMapFish Locator Filter"
changed = pyqtSignal()
@@ -77,7 +91,7 @@ def displayName(self) -> str:
return self.service.name
def prefix(self) -> str:
- return 'gmf'
+ return "gmf"
def hasConfigWidget(self) -> bool:
return True
@@ -91,10 +105,10 @@ def openConfigWidget(self, parent=None):
def reset_rubberband(self):
# this should happen on main thread only!
- self.rubberband.setColor(self.settings.value('point_color'))
+ self.rubberband.setColor(self.settings.value("point_color"))
self.rubberband.setIcon(self.rubberband.ICON_CIRCLE)
- self.rubberband.setIconSize(self.settings.value('point_size'))
- self.rubberband.setWidth(self.settings.value('line_width'))
+ self.rubberband.setIconSize(self.settings.value("point_size"))
+ self.rubberband.setWidth(self.settings.value("line_width"))
self.rubberband.setBrushStyle(Qt.NoBrush)
@staticmethod
@@ -109,10 +123,10 @@ def url_with_param(url, params) -> str:
def emit_bad_configuration(self, err=None):
result = QgsLocatorResult()
result.filter = self
- result.displayString = self.tr('Locator filter is not configured.')
- result.description = err if err else self.tr('Double-click to configure it.')
+ result.displayString = self.tr("Locator filter is not configured.")
+ result.description = err if err else self.tr("Double-click to configure it.")
result.userData = FilterNotConfigured
- result.icon = QgsApplication.getThemeIcon('mIconWarning.svg')
+ result.icon = QgsApplication.getThemeIcon("mIconWarning.svg")
self.resultFetched.emit(result)
return
@@ -136,15 +150,15 @@ def fetchResults(self, search, context, feedback):
return
params = {
- 'query': search,
- 'limit': str(self.service.total_limit),
- 'partitionlimit': str(self.service.category_limit)
+ "query": search,
+ "limit": str(self.service.total_limit),
+ "partitionlimit": str(self.service.category_limit),
}
url = self.url_with_param(url, params)
self.dbg_info(url.url())
_request = QNetworkRequest(url)
- _request.setRawHeader(b'User-Agent', self.USER_AGENT)
+ _request.setRawHeader(b"User-Agent", self.USER_AGENT)
request = QgsBlockingNetworkRequest()
if self.service.authid:
request.setAuthCfg(self.service.authid)
@@ -160,27 +174,29 @@ def fetchResults(self, search, context, feedback):
def handle_response(self, content: QByteArray):
try:
- data = json.loads(str(content.data(), encoding='utf-8'))
+ data = json.loads(str(content.data(), encoding="utf-8"))
# self.dbg_info(data)
- features = data['features']
+ features = data["features"]
for f in features:
- json_geom = json.dumps(f['geometry'])
+ json_geom = json.dumps(f["geometry"])
ogr_geom = ogr.CreateGeometryFromJson(json_geom)
wkt = ogr_geom.ExportToWkt()
geometry = QgsGeometry.fromWkt(wkt)
- self.dbg_info('---------')
+ self.dbg_info("---------")
self.dbg_info(QgsWkbTypes.geometryDisplayString(geometry.type()))
self.dbg_info(f.keys())
- self.dbg_info('{} {}'.format(f['properties']['layer_name'], f['properties']['label']))
- self.dbg_info(f['bbox'])
- self.dbg_info(f['geometry'])
+ self.dbg_info(
+ "{} {}".format(f["properties"]["layer_name"], f["properties"]["label"])
+ )
+ self.dbg_info(f["bbox"])
+ self.dbg_info(f["geometry"])
if geometry is None:
continue
result = QgsLocatorResult()
result.filter = self
- result.displayString = f['properties']['label']
- result.group = self.beautify_group(f['properties']['layer_name'])
+ result.displayString = f["properties"]["label"]
+ result.group = self.beautify_group(f["properties"]["layer_name"])
result.userData = geometry
self.resultFetched.emit(result)
@@ -211,7 +227,10 @@ def triggerResult(self, result):
except AttributeError:
# QGIS < 3.10 handling
from qgis.core import QgsCoordinateTransform, QgsProject
- transform = QgsCoordinateTransform(self.crs, self.map_canvas.mapSettings().destinationCrs(), QgsProject.instance())
+
+ transform = QgsCoordinateTransform(
+ self.crs, self.map_canvas.mapSettings().destinationCrs(), QgsProject.instance()
+ )
geometry.transform(transform)
rect = geometry.boundingBox()
rect.scale(4)
@@ -221,11 +240,18 @@ def triggerResult(self, result):
if geometry.type() == QgsWkbTypes.PolygonGeometry:
nflash = 16
- color1: QColor = self.settings.value('polygon_color')
+ color1: QColor = self.settings.value("polygon_color")
color2 = color1
color1.setAlpha(200)
color2.setAlpha(100)
- self.map_canvas.flashGeometries([geometry], self.crs, color1, color2, nflash, self.settings.value('highlight_duration')/nflash*1000)
+ self.map_canvas.flashGeometries(
+ [geometry],
+ self.crs,
+ color1,
+ color2,
+ nflash,
+ self.settings.value("highlight_duration") / nflash * 1000,
+ )
else:
self.rubberband.reset(geometry.type())
self.rubberband.addGeometry(geometry, self.crs)
@@ -233,11 +259,11 @@ def triggerResult(self, result):
self.current_timer = QTimer()
self.current_timer.timeout.connect(self.clear_results)
self.current_timer.setSingleShot(True)
- self.current_timer.start(self.settings.value('highlight_duration')*1000)
+ self.current_timer.start(self.settings.value("highlight_duration") * 1000)
def beautify_group(self, group) -> str:
if self.service.remove_leading_digits:
- group = re.sub('^[0-9]+', '', group)
+ group = re.sub("^[0-9]+", "", group)
if self.service.replace_underscore:
group = group.replace("_", " ")
if self.service.break_camelcase:
@@ -245,7 +271,7 @@ def beautify_group(self, group) -> str:
return group
def info(self, msg="", level=Qgis.Info):
- QgsMessageLog.logMessage('{} {}'.format(self.__class__.__name__, msg), 'QgsLocatorFilter', level)
+ QgsMessageLog.logMessage(f"{self.__class__.__name__} {msg}", "QgsLocatorFilter", level)
def dbg_info(self, msg=""):
if DEBUG:
@@ -253,6 +279,5 @@ def dbg_info(self, msg=""):
@staticmethod
def break_camelcase(identifier) -> str:
- matches = re.finditer('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)', identifier)
- return ' '.join([m.group(0) for m in matches])
-
+ matches = re.finditer(".+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)", identifier)
+ return " ".join([m.group(0) for m in matches])
diff --git a/geomapfish_locator/core/old_version_import.py b/geomapfish_locator/core/old_version_import.py
index aa78dd0..14b6318 100644
--- a/geomapfish_locator/core/old_version_import.py
+++ b/geomapfish_locator/core/old_version_import.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
/***************************************************************************
@@ -17,32 +16,49 @@
***************************************************************************/
"""
-from qgis.PyQt.QtCore import QObject, QCoreApplication
+from qgis.core import QgsApplication, QgsAuthMethodConfig, QgsSettings
+from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtWidgets import QMessageBox
-from qgis.core import QgsSettings, QgsAuthMethodConfig, QgsApplication
+
from .service import Service
-from .utils import info, dbg_info
+from .utils import dbg_info, info
def old_version_import() -> Service:
settings = QgsSettings()
- if settings.contains('plugins/geomapfsih_locator_plugin/geomapfish_url'):
+ if settings.contains("plugins/geomapfsih_locator_plugin/geomapfish_url"):
definition = dict()
- definition['name'] = settings.value('plugins/geomapfsih_locator_plugin/filter_name', 'geomapfish', type=str)
- definition['url'] = settings.value('plugins/geomapfsih_locator_plugin/geomapfish_url', '', type=str)
- definition['crs'] = settings.value('plugins/geomapfsih_locator_plugin/geomapfish_crs', '', type=str)
-
- definition['remove_leading_digits'] = settings.value('plugins/geomapfsih_locator_plugin/remove_leading_digits', True, type=bool)
- definition['replace_underscore'] = settings.value('plugins/geomapfsih_locator_plugin/replace_underscore', True, type=bool)
- definition['break_camelcase'] = settings.value('plugins/geomapfsih_locator_plugin/break_camelcase', True, type=bool)
-
- definition['category_limit'] = settings.value('plugins/geomapfsih_locator_plugin/category_limit', 8, type=int)
- definition['total_limit'] = settings.value('plugins/geomapfsih_locator_plugin/total_limit', 50, type=int)
-
- user = settings.value('plugins/geomapfsih_locator_plugin/geomapfish_user', '', type=str)
- pwd = settings.value('plugins/geomapfsih_locator_plugin/geomapfish_pass', '', type=str)
-
- info("importing old service: {}".format(definition))
+ definition["name"] = settings.value(
+ "plugins/geomapfsih_locator_plugin/filter_name", "geomapfish", type=str
+ )
+ definition["url"] = settings.value(
+ "plugins/geomapfsih_locator_plugin/geomapfish_url", "", type=str
+ )
+ definition["crs"] = settings.value(
+ "plugins/geomapfsih_locator_plugin/geomapfish_crs", "", type=str
+ )
+
+ definition["remove_leading_digits"] = settings.value(
+ "plugins/geomapfsih_locator_plugin/remove_leading_digits", True, type=bool
+ )
+ definition["replace_underscore"] = settings.value(
+ "plugins/geomapfsih_locator_plugin/replace_underscore", True, type=bool
+ )
+ definition["break_camelcase"] = settings.value(
+ "plugins/geomapfsih_locator_plugin/break_camelcase", True, type=bool
+ )
+
+ definition["category_limit"] = settings.value(
+ "plugins/geomapfsih_locator_plugin/category_limit", 8, type=int
+ )
+ definition["total_limit"] = settings.value(
+ "plugins/geomapfsih_locator_plugin/total_limit", 50, type=int
+ )
+
+ user = settings.value("plugins/geomapfsih_locator_plugin/geomapfish_user", "", type=str)
+ pwd = settings.value("plugins/geomapfsih_locator_plugin/geomapfish_pass", "", type=str)
+
+ info(f"importing old service: {definition}")
if user:
reply = QMessageBox.question(
@@ -52,17 +68,17 @@ def old_version_import() -> Service:
"Geomapfish Locator",
"User and password were saved in clear text in former Geomapfish plugin. "
"Would you like to use QGIS authentication to store these credentials? "
- "If not, they will be removed."
- )
+ "If not, they will be removed.",
+ ),
)
if reply == QMessageBox.Yes:
- config = QgsAuthMethodConfig('Basic')
- config.setName('geomapfish_{}'.format(definition['name']))
- config.setConfig('username', user)
- config.setConfig('password', pwd)
+ config = QgsAuthMethodConfig("Basic")
+ config.setName("geomapfish_{}".format(definition["name"]))
+ config.setConfig("username", user)
+ config.setConfig("password", pwd)
QgsApplication.authManager().storeAuthenticationConfig(config)
- definition['authid'] = config.id()
- dbg_info("created new auth id: {}".format(config.id()))
+ definition["authid"] = config.id()
+ dbg_info(f"created new auth id: {config.id()}")
else:
drop_keys()
return None
@@ -77,19 +93,16 @@ def old_version_import() -> Service:
def drop_keys():
settings = QgsSettings()
- settings.remove('plugins/geomapfsih_locator_plugin/filter_name')
- settings.remove('plugins/geomapfsih_locator_plugin/geomapfish_url')
- settings.remove('plugins/geomapfsih_locator_plugin/geomapfish_crs')
-
- settings.remove('plugins/geomapfsih_locator_plugin/remove_leading_digits')
- settings.remove('plugins/geomapfsih_locator_plugin/replace_underscore')
- settings.remove('plugins/geomapfsih_locator_plugin/break_camelcase')
-
- settings.remove('plugins/geomapfsih_locator_plugin/category_limit')
- settings.remove('plugins/geomapfsih_locator_plugin/total_limit')
-
- settings.remove('plugins/geomapfsih_locator_plugin/geomapfish_user')
- settings.remove('plugins/geomapfsih_locator_plugin/geomapfish_pass')
+ settings.remove("plugins/geomapfsih_locator_plugin/filter_name")
+ settings.remove("plugins/geomapfsih_locator_plugin/geomapfish_url")
+ settings.remove("plugins/geomapfsih_locator_plugin/geomapfish_crs")
+ settings.remove("plugins/geomapfsih_locator_plugin/remove_leading_digits")
+ settings.remove("plugins/geomapfsih_locator_plugin/replace_underscore")
+ settings.remove("plugins/geomapfsih_locator_plugin/break_camelcase")
+ settings.remove("plugins/geomapfsih_locator_plugin/category_limit")
+ settings.remove("plugins/geomapfsih_locator_plugin/total_limit")
+ settings.remove("plugins/geomapfsih_locator_plugin/geomapfish_user")
+ settings.remove("plugins/geomapfsih_locator_plugin/geomapfish_pass")
diff --git a/geomapfish_locator/core/service.py b/geomapfish_locator/core/service.py
index accff71..6254e08 100644
--- a/geomapfish_locator/core/service.py
+++ b/geomapfish_locator/core/service.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
/***************************************************************************
@@ -22,18 +21,18 @@
class Service:
def __init__(self, definition: dict = {}):
- self.name = definition.get('name')
- self.url = definition.get('url')
- self.crs = definition.get('crs')
- self.authid = definition.get('authid')
+ self.name = definition.get("name")
+ self.url = definition.get("url")
+ self.crs = definition.get("crs")
+ self.authid = definition.get("authid")
- self.category_limit = definition.get('category_limit', 8)
- self.total_limit = definition.get('total_limit', 40)
+ self.category_limit = definition.get("category_limit", 8)
+ self.total_limit = definition.get("total_limit", 40)
# beautify group names
- self.remove_leading_digits = definition.get('remove_leading_digits', True)
- self.replace_underscore = definition.get('replace_underscore', True)
- self.break_camelcase = definition.get('break_camelcase', True)
+ self.remove_leading_digits = definition.get("remove_leading_digits", True)
+ self.replace_underscore = definition.get("replace_underscore", True)
+ self.break_camelcase = definition.get("break_camelcase", True)
def is_valid(self):
if not self.name or not self.url or not self.crs:
@@ -45,16 +44,13 @@ def clone(self):
def as_dict(self) -> dict:
return {
- 'name': self.name,
- 'url': self.url,
- 'crs': self.crs,
- 'authid': self.authid,
- 'category_limit': self.category_limit,
- 'total_limit': self.total_limit,
- 'remove_leading_digits': self.remove_leading_digits,
- 'replace_underscore': self.replace_underscore,
- 'break_camelcase': self.break_camelcase
+ "name": self.name,
+ "url": self.url,
+ "crs": self.crs,
+ "authid": self.authid,
+ "category_limit": self.category_limit,
+ "total_limit": self.total_limit,
+ "remove_leading_digits": self.remove_leading_digits,
+ "replace_underscore": self.replace_underscore,
+ "break_camelcase": self.break_camelcase,
}
-
-
-
diff --git a/geomapfish_locator/core/settings.py b/geomapfish_locator/core/settings.py
index 8be35c7..9e012af 100644
--- a/geomapfish_locator/core/settings.py
+++ b/geomapfish_locator/core/settings.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
/***************************************************************************
@@ -18,7 +17,14 @@
"""
from qgis.PyQt.QtGui import QColor
-from geomapfish_locator.qgissettingmanager import SettingManager, Scope, List, Integer, Color
+
+from geomapfish_locator.qgissettingmanager import (
+ Color,
+ Integer,
+ List,
+ Scope,
+ SettingManager,
+)
pluginName = "geomapfsih_locator_plugin"
@@ -26,12 +32,15 @@
class Settings(SettingManager):
def __init__(self):
SettingManager.__init__(self, pluginName)
- self.add_setting(List('services', Scope.Global, []))
-
- self.add_setting(Integer('highlight_duration', Scope.Global, 8))
-
- self.add_setting(Integer('point_size', Scope.Global, 20))
- self.add_setting(Integer('line_width', Scope.Global, 4))
- self.add_setting(Color('polygon_color', Scope.Global, QColor(0, 100, 255, 200), allow_alpha=True))
- self.add_setting(Color('point_color', Scope.Global, QColor(255, 255, 50), allow_alpha=False))
-
+ self.add_setting(List("services", Scope.Global, []))
+
+ self.add_setting(Integer("highlight_duration", Scope.Global, 8))
+
+ self.add_setting(Integer("point_size", Scope.Global, 20))
+ self.add_setting(Integer("line_width", Scope.Global, 4))
+ self.add_setting(
+ Color("polygon_color", Scope.Global, QColor(0, 100, 255, 200), allow_alpha=True)
+ )
+ self.add_setting(
+ Color("point_color", Scope.Global, QColor(255, 255, 50), allow_alpha=False)
+ )
diff --git a/geomapfish_locator/core/utils.py b/geomapfish_locator/core/utils.py
index 9362602..3939bcb 100644
--- a/geomapfish_locator/core/utils.py
+++ b/geomapfish_locator/core/utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
/***************************************************************************
@@ -17,30 +16,31 @@
***************************************************************************/
"""
-from qgis.core import Qgis, QgsMessageLog
-from qgis.utils import iface
import re
import unicodedata
+from qgis.core import Qgis, QgsMessageLog
+from qgis.utils import iface
+
DEBUG = True
PLUGIN_NAME = "Geomapfish Locator Filters"
def info(message: str, level: Qgis.MessageLevel = Qgis.Info):
- QgsMessageLog.logMessage("{}: {}".format(PLUGIN_NAME, message), "Locator bar", level)
- iface.messageBar().pushMessage('Geomapfish Locator', message, level)
+ QgsMessageLog.logMessage(f"{PLUGIN_NAME}: {message}", "Locator bar", level)
+ iface.messageBar().pushMessage("Geomapfish Locator", message, level)
def dbg_info(message: str):
if DEBUG:
- QgsMessageLog.logMessage("{}: {}".format(PLUGIN_NAME, message), "Locator bar", Qgis.Info)
+ QgsMessageLog.logMessage(f"{PLUGIN_NAME}: {message}", "Locator bar", Qgis.Info)
def slugify(text: str) -> str:
# https://stackoverflow.com/q/5574042/1548052
- slug = unicodedata.normalize('NFKD', text)
+ slug = unicodedata.normalize("NFKD", text)
# slug = slug.encode('ascii', 'ignore').lower()
- slug = re.sub(r'[^a-z0-9]+', '-', slug).strip('-')
- slug = re.sub(r'[-]+', '-', slug)
+ slug = re.sub(r"[^a-z0-9]+", "-", slug).strip("-")
+ slug = re.sub(r"[-]+", "-", slug)
return slug
diff --git a/geomapfish_locator/gui/filter_configuration_dialog.py b/geomapfish_locator/gui/filter_configuration_dialog.py
index 1234eb9..75e2873 100644
--- a/geomapfish_locator/gui/filter_configuration_dialog.py
+++ b/geomapfish_locator/gui/filter_configuration_dialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# -----------------------------------------------------------
#
# QGIS Geomapfish Locator Plugin
@@ -26,11 +25,12 @@
import os
+
from qgis.core import QgsCoordinateReferenceSystem
from qgis.PyQt.QtWidgets import QDialog
from qgis.PyQt.uic import loadUiType
-DialogUi, _ = loadUiType(os.path.join(os.path.dirname(__file__), '../ui/filter_configuration.ui'))
+DialogUi, _ = loadUiType(os.path.join(os.path.dirname(__file__), "../ui/filter_configuration.ui"))
class FilterConfigurationDialog(QDialog, DialogUi):
@@ -41,7 +41,7 @@ def __init__(self, service, parent=None):
self.service = service.clone()
self.accepted.connect(self.save_service)
-
+
self.name.setText(service.name)
self.crs.setCrs(QgsCoordinateReferenceSystem(service.crs))
self.url.setText(service.url)
@@ -66,5 +66,3 @@ def save_service(self):
self.service.category_limit = self.category_limit.value()
self.service.total_limit = self.total_limit.value()
-
-
diff --git a/geomapfish_locator/gui/geomapfish_settings_dialog.py b/geomapfish_locator/gui/geomapfish_settings_dialog.py
index 4a7635b..69ec4e2 100644
--- a/geomapfish_locator/gui/geomapfish_settings_dialog.py
+++ b/geomapfish_locator/gui/geomapfish_settings_dialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# -----------------------------------------------------------
#
# QGIS Geomapfish Locator Plugin
@@ -29,12 +28,10 @@
from qgis.PyQt.QtWidgets import QDialog
from qgis.PyQt.uic import loadUiType
-from geomapfish_locator.qgissettingmanager import SettingDialog, UpdateMode
-
from geomapfish_locator.core.settings import Settings
+from geomapfish_locator.qgissettingmanager import SettingDialog, UpdateMode
-
-DialogUi, _ = loadUiType(os.path.join(os.path.dirname(__file__), '../ui/geomapfish_settings.ui'))
+DialogUi, _ = loadUiType(os.path.join(os.path.dirname(__file__), "../ui/geomapfish_settings.ui"))
class GeomapfishSettingsDialog(QDialog, DialogUi, SettingDialog):
diff --git a/geomapfish_locator/icons/warning.svg b/geomapfish_locator/icons/warning.svg
index 94d2a50..d3b8553 100644
--- a/geomapfish_locator/icons/warning.svg
+++ b/geomapfish_locator/icons/warning.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/requirements.txt b/requirements.txt
index 66a2100..4304b33 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1 @@
-qgis-plugin-ci
\ No newline at end of file
+qgis-plugin-ci