From 5c65149d153e6f32ee6bb02f722774c8258782a3 Mon Sep 17 00:00:00 2001 From: Jeff Osundwa Date: Fri, 20 Sep 2024 15:36:09 +0300 Subject: [PATCH] black formating --- geest/__init__.py | 28 +++---- geest/gui/geest_settings.py | 14 ++-- geest/gui/geest_treeview.py | 13 ++-- geest/gui/toggle_switch.py | 4 +- geest/gui/tree_panel.py | 45 ++++++++---- geest/gui/widgets/geest_config_widget.py | 65 ++++++++++++----- geest/gui/widgets/geest_widget_factory.py | 89 ++++++++++++++--------- geest/test-old/__init__.py | 1 + 8 files changed, 165 insertions(+), 94 deletions(-) diff --git a/geest/__init__.py b/geest/__init__.py index 3cc2414f..f4bf1a04 100644 --- a/geest/__init__.py +++ b/geest/__init__.py @@ -27,9 +27,9 @@ from qgis.PyQt.QtWidgets import QMessageBox, QPushButton, QAction, QDockWidget from qgis.core import Qgis -#from .geest import Geest -#from .core import RenderQueue, setting -from .core import setting #, JSONValidator +# from .geest import Geest +# from .core import RenderQueue, setting +from .core import setting # , JSONValidator from .utilities import resources_path from .gui import GeestOptionsFactory, GeestDock @@ -46,26 +46,29 @@ class GeestPlugin: def __init__(self, iface): self.iface = iface - #self.render_queue: Optional[RenderQueue] = None + # self.render_queue: Optional[RenderQueue] = None self.run_action: Optional[QAction] = None self.debug_action: Optional[QAction] = None self.options_factory = None def initGui(self): # pylint: disable=missing-function-docstring - #self.render_queue = RenderQueue() + # self.render_queue = RenderQueue() icon = QIcon(resources_path("resources", "geest-main.svg")) # Validate our json schema first - #validator = JSONValidator('resources/schema.json', 'resources/model.json') - #validator.validate_json() + # validator = JSONValidator('resources/schema.json', 'resources/model.json') + # validator.validate_json() self.run_action = QAction(icon, "GEEST", self.iface.mainWindow()) self.run_action.triggered.connect(self.run) self.iface.addToolBarIcon(self.run_action) - self.dock_widget = GeestDock(parent=self.iface.mainWindow(), json_file=resources_path("resources", "model.json")) + self.dock_widget = GeestDock( + parent=self.iface.mainWindow(), + json_file=resources_path("resources", "model.json"), + ) self.dock_widget.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) - #self.dock_widget.setWidget(Geest(self.iface.mainWindow(), self.iface)) + # self.dock_widget.setWidget(Geest(self.iface.mainWindow(), self.iface)) self.dock_widget.setFloating(False) self.dock_widget.setFeatures(QDockWidget.DockWidgetMovable) self.iface.addDockWidget(Qt.RightDockWidgetArea, self.dock_widget) @@ -85,7 +88,7 @@ def initGui(self): # pylint: disable=missing-function-docstring debug_env = int(os.getenv("GEEST_DEBUG", 0)) if debug_env: self.debug() - + self.options_factory = GeestOptionsFactory() self.iface.registerOptionsWidgetFactory(self.options_factory) @@ -125,9 +128,8 @@ def run(self): """ # Create the settings dialog self.iface.showOptionsDialog( - parent=self.iface.mainWindow(), - currentPage='geest') - + parent=self.iface.mainWindow(), currentPage="geest" + ) def display_information_message_bar( self, diff --git a/geest/gui/geest_settings.py b/geest/gui/geest_settings.py index b591d38c..928f3a75 100644 --- a/geest/gui/geest_settings.py +++ b/geest/gui/geest_settings.py @@ -26,9 +26,9 @@ def __init__(self, parent=None): """ QgsOptionsPageWidget.__init__(self, parent) self.setupUi(self) - # We need this so we can open the settings to our own + # We need this so we can open the settings to our own # page from the plugin button bar. - self.setObjectName('geest') + self.setObjectName("geest") # The maximum number of concurrent threads to allow # during rendering. Probably setting to the same number # of CPU cores you have would be a good conservative approach @@ -41,8 +41,8 @@ def __init__(self, parent=None): if edit_mode: self.edit_mode_checkbox.setChecked(True) else: - self.edit_mode_checkbox.setChecked(False) - + self.edit_mode_checkbox.setChecked(False) + # This is intended for developers to attach to the plugin using a # remote debugger so that they can step through the code. Do not # enable it if you do not have a remote debugger set up as it will @@ -69,12 +69,12 @@ def apply(self): key="render_thread_pool_size", value=self.spin_thread_pool_size.value(), ) - + if self.edit_mode_checkbox.isChecked(): set_setting(key="edit_mode", value=1) else: - set_setting(key="edit_mode", value=0) - + set_setting(key="edit_mode", value=0) + if self.debug_mode_checkbox.isChecked(): set_setting(key="debug_mode", value=1) else: diff --git a/geest/gui/geest_treeview.py b/geest/gui/geest_treeview.py index 260ce8f0..4321b1ba 100644 --- a/geest/gui/geest_treeview.py +++ b/geest/gui/geest_treeview.py @@ -166,20 +166,19 @@ def setData(self, index, value, role=Qt.EditRole): def flags(self, index): """Allow editing of the name and weighting columns.""" - - #Override the flags method to allow specific columns to be editable. - + + # Override the flags method to allow specific columns to be editable. + if not index.isValid(): return Qt.NoItemFlags - + item = index.internalPointer() # For example, only allow editing for the first and second columns if index.column() == 0 or index.column() == 1: return Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsEnabled - return Qt.ItemIsSelectable | Qt.ItemIsEnabled - - + return Qt.ItemIsSelectable | Qt.ItemIsEnabled + def update_font_color(self, item, color): """Update the font color of an item.""" item.font_color = color diff --git a/geest/gui/toggle_switch.py b/geest/gui/toggle_switch.py index ff84e70e..d23b8a1c 100644 --- a/geest/gui/toggle_switch.py +++ b/geest/gui/toggle_switch.py @@ -20,7 +20,9 @@ def paintEvent(self, event): # Background color based on state if self.checked: - painter.setBrush(QColor("#002244")) # Active state color (blue) from WB Style Guide + painter.setBrush( + QColor("#002244") + ) # Active state color (blue) from WB Style Guide else: painter.setBrush(QColor("#ADB5BD")) # Inactive state color (gray) diff --git a/geest/gui/tree_panel.py b/geest/gui/tree_panel.py index 8e96aa5b..3fc31131 100644 --- a/geest/gui/tree_panel.py +++ b/geest/gui/tree_panel.py @@ -20,11 +20,12 @@ import json import os from .geest_treeview import CustomTreeView, JsonTreeModel -from .setup_panel import SetupPanel +from .setup_panel import SetupPanel from .layer_detail_dialog import LayerDetailDialog from geest.utilities import resources_path from geest.core import set_setting, setting + class TreePanel(QWidget): def __init__(self, parent=None, json_file=None): super().__init__(parent) @@ -40,7 +41,7 @@ def __init__(self, parent=None, json_file=None): else: self.json_data = {"dimensions": []} - # Create a CustomTreeView widget to handle editing and reverts + # Create a CustomTreeView widget to handle editing and reverts self.treeView = CustomTreeView() self.treeView.setDragDropMode(QTreeView.InternalMove) self.treeView.setDefaultDropAction(Qt.MoveAction) @@ -93,7 +94,7 @@ def __init__(self, parent=None, json_file=None): self.prepare_button = QPushButton("▶️ Prepare") self.prepare_button.clicked.connect(self.process_leaves) movie.start() - + # Add Edit Toggle checkbox self.edit_toggle = QCheckBox("Edit") self.edit_toggle.setChecked(False) @@ -102,8 +103,8 @@ def __init__(self, parent=None, json_file=None): if edit_mode: self.edit_toggle.setVisible(True) else: - self.edit_toggle.setVisible(False) - + self.edit_toggle.setVisible(False) + button_bar.addWidget(self.add_dimension_button) button_bar.addStretch() @@ -115,7 +116,7 @@ def __init__(self, parent=None, json_file=None): button_bar.addWidget(self.edit_toggle) # Add the edit toggle layout.addLayout(button_bar) self.setLayout(layout) - + def edit(self, index, trigger, event): """ Override the edit method to enable editing only on the column that was clicked. @@ -239,7 +240,8 @@ def show_layer_properties(self, item): # Create and show the LayerDetailDialog dialog = LayerDetailDialog( - layer_name, layer_data, item, editing=editing, parent=self) + layer_name, layer_data, item, editing=editing, parent=self + ) # Connect the dialog's dataUpdated signal to handle data updates def update_layer_data(updated_data): @@ -247,8 +249,8 @@ def update_layer_data(updated_data): item.setData(3, updated_data) # Check if the layer name has changed, and if so, update it in column 0 - if updated_data.get('name', layer_name) != layer_name: - item.setData(0, updated_data.get('name', layer_name)) + if updated_data.get("name", layer_name) != layer_name: + item.setData(0, updated_data.get("name", layer_name)) # Connect the signal emitted from the dialog to update the item dialog.dataUpdated.connect(update_layer_data) @@ -273,7 +275,7 @@ def process_leaves(self): """ This function processes all nodes in the QTreeView that have the 'layer' role. It iterates over the entire tree, collecting nodes with the 'layer' role, and - processes each one by showing an animated icon, waiting for 2 seconds, and + processes each one by showing an animated icon, waiting for 2 seconds, and then removing the animation. """ model = self.treeView.model() # Get the model from the tree_view @@ -302,7 +304,7 @@ def collect_layer_nodes(self, model, parent_index, layer_nodes): item = parent_index.internalPointer() # If the item is a 'layer', add it to the list of nodes to process - if item and getattr(item, 'role', None) == 'layer': + if item and getattr(item, "role", None) == "layer": layer_nodes.append(parent_index) # Process all child items recursively @@ -329,9 +331,17 @@ def process_each_layer(self, layer_nodes, index): second_column_index = model.index(node_index.row(), 1, node_index.parent()) # Set an animated icon (using a QLabel and QMovie to simulate animation) - movie = QMovie(resources_path("resources", "throbber.gif")) # Use a valid path to an animated gif - row_height = self.treeView.rowHeight(node_index) # Get the height of the current row - movie.setScaledSize(movie.currentPixmap().size().scaled(row_height, row_height, Qt.KeepAspectRatio)) + movie = QMovie( + resources_path("resources", "throbber.gif") + ) # Use a valid path to an animated gif + row_height = self.treeView.rowHeight( + node_index + ) # Get the height of the current row + movie.setScaledSize( + movie.currentPixmap() + .size() + .scaled(row_height, row_height, Qt.KeepAspectRatio) + ) label = QLabel() label.setMovie(movie) @@ -341,7 +351,12 @@ def process_each_layer(self, layer_nodes, index): self.treeView.setIndexWidget(second_column_index, label) # Wait for 2 seconds to simulate processing - QTimer.singleShot(2000, lambda: self.finish_processing(second_column_index, layer_nodes, index, movie)) + QTimer.singleShot( + 2000, + lambda: self.finish_processing( + second_column_index, layer_nodes, index, movie + ), + ) def finish_processing(self, second_column_index, layer_nodes, index, movie): """ diff --git a/geest/gui/widgets/geest_config_widget.py b/geest/gui/widgets/geest_config_widget.py index a94ef667..52bbceeb 100644 --- a/geest/gui/widgets/geest_config_widget.py +++ b/geest/gui/widgets/geest_config_widget.py @@ -1,10 +1,16 @@ from qgis.PyQt.QtWidgets import ( - QWidget, QVBoxLayout, QRadioButton, QLineEdit, - QSpinBox, QDoubleSpinBox, QComboBox + QWidget, + QVBoxLayout, + QRadioButton, + QLineEdit, + QSpinBox, + QDoubleSpinBox, + QComboBox, ) from qgis.PyQt.QtCore import pyqtSignal from qgis.gui import QgsMapLayerComboBox -#from qgis.core import QgsVectorLayer, QgsRasterLayer + +# from qgis.core import QgsVectorLayer, QgsRasterLayer from qgis.core import QgsProviderRegistry from .geest_widget_factory import GeestWidgetFactory @@ -26,14 +32,18 @@ def create_widgets(self): self.setLayout(layout) print("Calling GeestWidgetFactory.create_widgets") - widgets_container = GeestWidgetFactory.create_widgets(self.original_config, self) + widgets_container = GeestWidgetFactory.create_widgets( + self.original_config, self + ) if widgets_container is None: print("GeestWidgetFactory.create_widgets returned None") return if not isinstance(widgets_container, QWidget): - print(f"GeestWidgetFactory.create_widgets returned unexpected type: {type(widgets_container)}") + print( + f"GeestWidgetFactory.create_widgets returned unexpected type: {type(widgets_container)}" + ) return if widgets_container.layout() is None: @@ -63,11 +73,16 @@ def recursive_find_and_store_widgets(self, widget, depth=0): self.widgets[use_key] = {} self.widgets[use_key]["radio"] = widget print(" " * depth + f"Stored QRadioButton for key: {use_key}") - elif isinstance(widget, (QLineEdit, QSpinBox, QDoubleSpinBox, QComboBox, QgsMapLayerComboBox)): + elif isinstance( + widget, + (QLineEdit, QSpinBox, QDoubleSpinBox, QComboBox, QgsMapLayerComboBox), + ): if use_key not in self.widgets: self.widgets[use_key] = {} self.widgets[use_key]["widget"] = widget - print(" " * depth + f"Stored {type(widget).__name__} for key: {use_key}") + print( + " " * depth + f"Stored {type(widget).__name__} for key: {use_key}" + ) if widget.layout(): for i in range(widget.layout().count()): @@ -81,18 +96,28 @@ def setup_connections(self): radio = widgets.get("radio") widget = widgets.get("widget") if radio: - radio.toggled.connect(lambda checked, k=key: self.handle_option_change(k, checked)) + radio.toggled.connect( + lambda checked, k=key: self.handle_option_change(k, checked) + ) print(f"Set up radio connection for {key}") if widget: if isinstance(widget, QgsMapLayerComboBox): print(f"Setting up connection for QgsMapLayerComboBox: {key}") - widget.layerChanged.connect(lambda layer, k=key: self.update_layer_path(k, layer)) + widget.layerChanged.connect( + lambda layer, k=key: self.update_layer_path(k, layer) + ) elif isinstance(widget, QLineEdit): - widget.textChanged.connect(lambda text, k=key: self.update_sub_widget_state(k, text)) + widget.textChanged.connect( + lambda text, k=key: self.update_sub_widget_state(k, text) + ) elif isinstance(widget, (QSpinBox, QDoubleSpinBox)): - widget.valueChanged.connect(lambda value, k=key: self.update_sub_widget_state(k, value)) + widget.valueChanged.connect( + lambda value, k=key: self.update_sub_widget_state(k, value) + ) elif isinstance(widget, QComboBox): - widget.currentTextChanged.connect(lambda text, k=key: self.update_sub_widget_state(k, text)) + widget.currentTextChanged.connect( + lambda text, k=key: self.update_sub_widget_state(k, text) + ) print(f"Set up widget connection for {key}: {type(widget).__name__}") def update_layer_path(self, key, layer): @@ -103,12 +128,14 @@ def update_layer_path(self, key, layer): print(f"Layer URI: {uri}") decoded = QgsProviderRegistry.instance().decodeUri(provider_key, uri) print(f"Decoded URI: {decoded}") - path = decoded.get('path') or decoded.get('url') or decoded.get('layerName') + path = decoded.get("path") or decoded.get("url") or decoded.get("layerName") if path: print(f"Path found: {path}") self.update_sub_widget_state(key, path) else: - print(f"Unable to determine path for layer {layer.name()} with provider {provider_key}") + print( + f"Unable to determine path for layer {layer.name()} with provider {provider_key}" + ) self.update_sub_widget_state(key, uri) # Fallback to using the full URI else: print(f"No layer selected for {key}") @@ -155,16 +182,20 @@ def update_widgets_from_config(self): if isinstance(widget, QLineEdit): widget.setText(str(value)) elif isinstance(widget, (QSpinBox, QDoubleSpinBox)): - widget.setValue(float(value) if isinstance(widget, QDoubleSpinBox) else int(value)) + widget.setValue( + float(value) + if isinstance(widget, QDoubleSpinBox) + else int(value) + ) elif isinstance(widget, (QComboBox, QgsMapLayerComboBox)): widget.setCurrentText(str(value)) def dump_widget_hierarchy(self, widget, level=0): output = [] output.append(" " * level + f"{widget.__class__.__name__}") - if hasattr(widget, 'layout') and widget.layout(): + if hasattr(widget, "layout") and widget.layout(): for i in range(widget.layout().count()): item = widget.layout().itemAt(i) if item.widget(): output.append(self.dump_widget_hierarchy(item.widget(), level + 1)) - return "\n".join(output) \ No newline at end of file + return "\n".join(output) diff --git a/geest/gui/widgets/geest_widget_factory.py b/geest/gui/widgets/geest_widget_factory.py index 85d93d72..28d6f31e 100644 --- a/geest/gui/widgets/geest_widget_factory.py +++ b/geest/gui/widgets/geest_widget_factory.py @@ -37,13 +37,13 @@ def create_widgets(layer_data: dict, parent=None): "max": 100.0, "decimals": 1, "default": layer_data.get("Default Index Score", 0.0), - "tooltip": "The default index score value." + "tooltip": "The default index score value.", }, "Use Multi Buffer Point": { "label": "Multi Buffer Distances", "type": "lineedit", "default": layer_data.get("Default Multi Buffer Distances", ""), - "tooltip": "Enter comma-separated buffer distances." + "tooltip": "Enter comma-separated buffer distances.", }, "Use Single Buffer Point": { "label": "Single Buffer Distance", @@ -51,7 +51,7 @@ def create_widgets(layer_data: dict, parent=None): "min": 0, "max": 10000, "default": layer_data.get("Default Single Buffer Distance", 0), - "tooltip": "Enter buffer distance." + "tooltip": "Enter buffer distance.", }, "Use Create Grid": { "label": "Pixel Size", @@ -59,90 +59,91 @@ def create_widgets(layer_data: dict, parent=None): "min": 0, "max": 10000, "default": layer_data.get("Default pixel", 0), - "tooltip": "Enter pixel size for grid creation." + "tooltip": "Enter pixel size for grid creation.", }, "Use Add Layers Manually": { "label": "Add Layers Manually", "description": "Using this option, you can add layers manually.", "type": "layer_selector", "layer_type": "vector", - "tooltip": "Select a vector layer." + "tooltip": "Select a vector layer.", }, "Use Classify Poly into Classes": { "label": "Classify Polygons into Classes", "description": "Using this option, you can classify polygons into classes.", "type": "layer_selector", "layer_type": "polygon", - "tooltip": "Select a polygon layer." + "tooltip": "Select a polygon layer.", }, "Use CSV to Point Layer": { "label": "Use CSV File", "description": "Using this option, you can convert a CSV file to a point layer.", "type": "csv_to_point", - "tooltip": "Select a CSV file and specify longitude and latitude columns." + "tooltip": "Select a CSV file and specify longitude and latitude columns.", }, "Use Poly per Cell": { "label": "Use Polygon Layer", "description": "Using this option, create a polygon per grid cell.", "type": "layer_selector", "layer_type": "polygon", - "tooltip": "Select a polygon layer." + "tooltip": "Select a polygon layer.", }, "Use Polyline per Cell": { "label": "Use Polyline Layer", "description": "Using this option, create a polyline per grid cell.", "type": "layer_selector", "layer_type": "line", - "tooltip": "Select a line layer." + "tooltip": "Select a line layer.", }, "Use Point per Cell": { "label": "Use Points Layer", "description": "Using this option, create a point per grid cell.", "type": "layer_selector", "layer_type": "point", - "tooltip": "Select a point layer." + "tooltip": "Select a point layer.", }, "Use Rasterize Layer": { "label": "Rasterize Layer", "description": "Using this option, you can rasterize a vector layer.", "type": "layer_selector", "layer_type": "all", - "tooltip": "Select a raster layer to rasterize." + "tooltip": "Select a raster layer to rasterize.", }, - "Use OSM Downloader": { "label": "Fetch the data from OSM", "description": "Using this option, we will try to fetch the data needed for this indicator directly from OSM.", "type": "download_option", - "tooltip": "Download data from OSM." + "tooltip": "Download data from OSM.", }, "Use WBL Downloader": { "label": "Fetch the data from WBL", "description": "Using this option, we will try to fetch the data needed for this indicator directly from WBL.", "type": "download_option", - "tooltip": "Download data from WBL." + "tooltip": "Download data from WBL.", }, "Use Humdata Downloader": { "label": "Fetch the data from HumData", "description": "Using this option, we will try to fetch the data needed for this indicator directly from HumData.", "type": "download_option", - "tooltip": "Download data from HumData." + "tooltip": "Download data from HumData.", }, "Use Mapillary Downloader": { "label": "Fetch the data from Mapillary", "description": "Using this option, we will try to fetch the data needed for this indicator directly from Mapillary.", "type": "download_option", - "tooltip": "Download data from Mapillary." + "tooltip": "Download data from Mapillary.", }, "Use Other Downloader": { "label": "Fetch the data from specified source", "description": f"Using this option, we will try to fetch the data needed for this indicator directly from {layer_data.get('Use Other Downloader', '')}.", "type": "download_option", - "tooltip": f"Download data from {layer_data.get('Use Other Downloader', 'Other Source')}." - } + "tooltip": f"Download data from {layer_data.get('Use Other Downloader', 'Other Source')}.", + }, } - use_keys_enabled = {k: v for k, v in layer_data.items() if k.startswith("Use") and v} + use_keys_enabled = { + k: v for k, v in layer_data.items() if k.startswith("Use") and v + } if not use_keys_enabled: return QWidget() @@ -181,7 +182,9 @@ def create_widgets(layer_data: dict, parent=None): main_layout.addWidget(option_container) - radio_button.toggled.connect(lambda checked, w=widget: w.setEnabled(checked)) + radio_button.toggled.connect( + lambda checked, w=widget: w.setEnabled(checked) + ) widget.setEnabled(False) # Initially disable all widgets if radio_group.buttons(): @@ -200,17 +203,17 @@ def create_specific_widget(mapping: dict, layer_data: dict): """ widget_type = mapping["type"] - #-- guard against GIGO + # -- guard against GIGO def safe_float(value, default): try: - return float(value) if value != '' else default + return float(value) if value != "" else default except (ValueError, TypeError): return default # -- guard against GIGO def safe_int(value, default): try: - return int(float(value)) if value != '' else default + return int(float(value)) if value != "" else default except (ValueError, TypeError): return default @@ -256,10 +259,14 @@ def safe_int(value, default): elif subtype_mapped == "point": widget.setFilters(QgsMapLayerProxyModel.PointLayer) else: - print(f"Invalid layer subtype '{layer_type}' for '{mapping.get('label')}'. Defaulting to all vector layers.") + print( + f"Invalid layer subtype '{layer_type}' for '{mapping.get('label')}'. Defaulting to all vector layers." + ) widget.setFilters(QgsMapLayerProxyModel.VectorLayer) else: - print(f"Unknown layer type '{layer_type}' for '{mapping.get('label')}'. Defaulting to all layers.") + print( + f"Unknown layer type '{layer_type}' for '{mapping.get('label')}'. Defaulting to all layers." + ) widget.setFilters(QgsMapLayerProxyModel.All) # Check if layers are available @@ -280,7 +287,11 @@ def safe_int(value, default): file_widget = QgsFileWidget(parent=container) file_widget.setFilter("CSV Files (*.csv);;All Files (*.*)") file_widget.setToolTip( - mapping.get("tooltip", "Select a CSV file containing longitude and latitude columns.")) + mapping.get( + "tooltip", + "Select a CSV file containing longitude and latitude columns.", + ) + ) layout.addWidget(file_widget) # Create layouts for longitude and latitude columns @@ -315,7 +326,9 @@ def safe_int(value, default): # Connect file selection to populate and auto-fill combo boxes file_widget.fileChanged.connect( - lambda path: GeestWidgetFactory.populate_csv_columns(path, longitude_combo, latitude_combo) + lambda path: GeestWidgetFactory.populate_csv_columns( + path, longitude_combo, latitude_combo + ) ) return container @@ -330,7 +343,9 @@ def safe_int(value, default): return None @staticmethod - def populate_csv_columns(file_path: str, lon_combo: QComboBox, lat_combo: QComboBox): + def populate_csv_columns( + file_path: str, lon_combo: QComboBox, lat_combo: QComboBox + ): """ Populate the longitude and latitude combo boxes based on the CSV file's headers. Auto-select columns if 'longitude'/'lon' and 'latitude'/'lat' are found. @@ -341,7 +356,7 @@ def populate_csv_columns(file_path: str, lon_combo: QComboBox, lat_combo: QCombo return try: - with open(file_path, newline='', encoding='utf-8') as csvfile: + with open(file_path, newline="", encoding="utf-8") as csvfile: reader = csv.reader(csvfile) headers = next(reader) lon_combo.clear() @@ -350,15 +365,21 @@ def populate_csv_columns(file_path: str, lon_combo: QComboBox, lat_combo: QCombo lat_combo.addItems(headers) # Auto-select longitude column - lon_candidates = ['longitude', 'lon'] - selected_lon = next((header for header in headers if header.lower() in lon_candidates), None) + lon_candidates = ["longitude", "lon"] + selected_lon = next( + (header for header in headers if header.lower() in lon_candidates), + None, + ) if selected_lon: index = headers.index(selected_lon) lon_combo.setCurrentIndex(index) # Auto-select latitude column - lat_candidates = ['latitude', 'lat'] - selected_lat = next((header for header in headers if header.lower() in lat_candidates), None) + lat_candidates = ["latitude", "lat"] + selected_lat = next( + (header for header in headers if header.lower() in lat_candidates), + None, + ) if selected_lat: index = headers.index(selected_lat) lat_combo.setCurrentIndex(index) @@ -370,4 +391,4 @@ def populate_csv_columns(file_path: str, lon_combo: QComboBox, lat_combo: QCombo lon_combo.clear() lat_combo.clear() lon_combo.setEnabled(False) - lat_combo.setEnabled(False) \ No newline at end of file + lat_combo.setEnabled(False) diff --git a/geest/test-old/__init__.py b/geest/test-old/__init__.py index 65c47b57..884794d9 100644 --- a/geest/test-old/__init__.py +++ b/geest/test-old/__init__.py @@ -1,4 +1,5 @@ """ import qgis libs so that we set the correct sip api version """ + import qgis # NOQA