Skip to content

Commit

Permalink
style: reformat w/ ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
koebi committed Dec 14, 2023
1 parent bfaf3ee commit 0d307e4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
37 changes: 20 additions & 17 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@
import os
import processing
import webbrowser
from qgis.core import (QgsProject,
QgsVectorLayer,
QgsTextAnnotation,
QgsMapLayerProxyModel,
QgsFeature,
QgsPointXY,
QgsGeometry,
QgsFields,
QgsField,
QgsCoordinateReferenceSystem
)
from qgis.core import (
QgsProject,
QgsVectorLayer,
QgsTextAnnotation,
QgsMapLayerProxyModel,
QgsFeature,
QgsPointXY,
QgsGeometry,
QgsFields,
QgsField,
QgsCoordinateReferenceSystem,
)
from qgis.gui import QgsMapCanvasAnnotationItem

from PyQt5.QtCore import QSizeF, QPointF, QCoreApplication, QVariant
Expand Down Expand Up @@ -439,19 +440,22 @@ def __init__(self, iface, parent=None):

def _save_vertices_to_layer(self):
"""Saves the vertices list to a temp layer"""
items = [self.routing_fromline_list.item(x).text() for x in range(self.routing_fromline_list.count())]
items = [
self.routing_fromline_list.item(x).text()
for x in range(self.routing_fromline_list.count())
]

if len(items) > 0:
crs = QgsCoordinateReferenceSystem("EPSG:4326")
fields = QgsFields()
fields.append(QgsField('ID', QVariant.Int))
point_layer = QgsVectorLayer("Point?crs=4326", 'Vertices', 'memory')
fields.append(QgsField("ID", QVariant.Int))
point_layer = QgsVectorLayer("Point?crs=4326", "Vertices", "memory")
point_layer.setCrs(crs)
point_layer.dataProvider().addAttributes(fields)
point_layer.updateFields()
for idx, x in enumerate(items):
coords = x.split(':')[1]
x, y = (float(i) for i in coords.split(', '))
coords = x.split(":")[1]
x, y = (float(i) for i in coords.split(", "))
feature = QgsFeature()
feature.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(x, y)))
feature.setAttributes([idx])
Expand Down Expand Up @@ -565,4 +569,3 @@ def _on_linetool_map_doubleclick(self):
QApplication.restoreOverrideCursor()
self._iface.mapCanvas().setMapTool(self.last_maptool)
self.show()

13 changes: 10 additions & 3 deletions ORStools/gui/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -6010,18 +6010,25 @@
\x00\x00\x01\x8a\xf0\x91\x1f\x2d\
"

qt_version = [int(v) for v in QtCore.qVersion().split('.')]
qt_version = [int(v) for v in QtCore.qVersion().split(".")]
if qt_version < [5, 8, 0]:
rcc_version = 1
qt_resource_struct = qt_resource_struct_v1
else:
rcc_version = 2
qt_resource_struct = qt_resource_struct_v2


def qInitResources():
QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
QtCore.qRegisterResourceData(
rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data
)


def qCleanupResources():
QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
QtCore.qUnregisterResourceData(
rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data
)


qInitResources()

0 comments on commit 0d307e4

Please sign in to comment.