Skip to content

Commit d238639

Browse files
committed
fix: pycodestlye issues
1 parent df493f2 commit d238639

16 files changed

Lines changed: 128 additions & 145 deletions

connection/networkaccessmanager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
"""
2323

2424

25-
__author__ = "Alessandro Pasotti"
26-
__date__ = "August 2016"
27-
2825
import sys
2926
import urllib
3027

3128
from qgis.core import QgsAuthManager, QgsMessageLog, QgsNetworkAccessManager
3229
from qgis.PyQt.QtCore import QEventLoop, QUrl
3330
from qgis.PyQt.QtNetwork import QNetworkReply, QNetworkRequest
3431

32+
__author__ = "Alessandro Pasotti"
33+
__date__ = "August 2016"
34+
3535
# FIXME: ignored
3636
DEFAULT_MAX_REDIRECTS = 4
3737

connection/shogunressource.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
This code is licensed under the GPL 2.0 license.
55
"""
66

7-
__author__ = "ntreff"
8-
__date__ = "July 2025"
97

108
import json
119
import os
@@ -18,15 +16,8 @@
1816
from qgis.PyQt.QtGui import QIcon
1917
from qgis.PyQt.QtNetwork import QHttpMultiPart, QHttpPart, QNetworkRequest
2018
from qgis.PyQt.QtXml import QDomDocument
21-
from qgis.PyQt.QtNetwork import QNetworkRequest, QHttpPart, QHttpMultiPart
22-
from qgis.PyQt.QtCore import QFile, QIODevice, QSize
23-
24-
from qgis.core import QgsApplication
25-
from qgis.gui import QgsMessageBar
2619

27-
from .networkaccessmanager import NetworkAccessManager, RequestsExceptionConnectionError, RequestsException
2820
from ..layerutils import createAndParseSld
29-
3021
from .networkaccessmanager import (
3122
NetworkAccessManager,
3223
RequestsException,
@@ -35,6 +26,9 @@
3526

3627
PYTHON_VERSION = sys.version_info[0]
3728

29+
__author__ = "ntreff"
30+
__date__ = "July 2025"
31+
3832

3933
class ShogunRessource:
4034
"""This class controls all interactions between QGIS and the Shogun ressource,
@@ -87,18 +81,17 @@ def checkConnection(self):
8781
if testresponse[0]["status"] > 199 and testresponse[0]["status"] < 210:
8882
return (True, "")
8983
except RequestsException as e:
84+
print('Error during connection test: ' + str(e))
9085
if self.baseurl.startswith("https"):
91-
# if the first try with 'https' was not successfull try http:
86+
# if the first try with 'https' was not successful try http:
9287
testurl = "http" + testurl[5:]
9388
try:
9489
testresponse = self.http.request(testurl, method="HEAD")
95-
if (
96-
testresponse[0]["status"] > 199
97-
and testresponse[0]["status"] < 210
98-
):
90+
if testresponse[0]["status"] > 199 and testresponse[0]["status"] < 210:
9991
self.baseurl = "http" + self.baseurl[5:]
10092
return (True, "")
10193
except RequestsException as e:
94+
print('Could not fetch fetch applications ' + str(e))
10295
pass
10396
return (False, "Error : Failed to connect to the server")
10497

@@ -450,17 +443,17 @@ def uploadLayer(self, pathToZipFile, dataType):
450443
def requestCrsUpdateOnLayer(self, importJobId):
451444
url = self.baseurl + "/import/update-crs-for-import.action"
452445
data = (
453-
"importJobId="
454-
+ str(importJobId)
455-
+ "&taskId=0&fileProjection=EPSG%3A3857&layerName=&dataType=Vector"
446+
"importJobId=" +
447+
str(importJobId) +
448+
"&taskId=0&fileProjection=EPSG%3A3857&layerName=&dataType=Vector"
456449
)
457450
h = {"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"}
458451
response = self.http.request(url, method="POST", body=data, headers=h)
459452

460453
def getFieldNamesFromWfs(self, layerRessourceName):
461454
url = (
462-
self.baseurl
463-
+ "geoserver-noauth.action?service=WFS&request=DescribeFeatureType&typeName="
455+
self.baseurl +
456+
"geoserver-noauth.action?service=WFS&request=DescribeFeatureType&typeName="
464457
)
465458
url += layerRessourceName + "&outputFormat=application/json"
466459
response = self.http.request(url)

gui/dialog_bases/addraster.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
(c) 2025 terrestris GmbH & Co. KG, https://www.terrestris.de/en/
44
This code is licensed under the GPL 2.0 license.
55
"""
6-
7-
__author__ = "ntreff"
8-
__date__ = "July 2025"
9-
106
import sys
117

128
if sys.version_info[0] >= 3:
@@ -16,6 +12,9 @@
1612
from PyQt4 import QtCore
1713
from PyQt4.QtGui import QDialog, QLabel, QPushButton
1814

15+
__author__ = "ntreff"
16+
__date__ = "July 2025"
17+
1918

2019
class AddRasterDialog(QDialog):
2120
def __init__(self):

gui/dialog_bases/applicationSettings.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
This code is licensed under the GPL 2.0 license.
55
"""
66

7-
__author__ = "ntreff"
8-
__date__ = "July 2025"
9-
107
import sys
118

129
from qgis.gui import QgsExtentGroupBox
@@ -18,6 +15,10 @@
1815
from qgis.PyQt.QtGui import QFont
1916

2017

18+
__author__ = "ntreff"
19+
__date__ = "July 2025"
20+
21+
2122
class LayerListItem(QtGui.QListWidgetItem):
2223
def __init__(self, text, layerId):
2324
super(LayerListItem, self).__init__(text)
@@ -51,12 +52,8 @@ class LayerTreeItem(QtGui.QTreeWidgetItem):
5152
def __init__(self, parent):
5253
super(LayerTreeItem, self).__init__(parent)
5354
self.setFlags(
54-
Qt.ItemIsEnabled
55-
| Qt.ItemIsSelectable
56-
| Qt.ItemIsDragEnabled
57-
| Qt.ItemIsSelectable
58-
| Qt.ItemIsUserCheckable
59-
| Qt.ItemIsDropEnabled
55+
Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled |
56+
Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsDropEnabled
6057
)
6158
self.savedAttributes = {}
6259
self.newAttributes = {}
@@ -70,7 +67,7 @@ def setSavedAttributes(self, savedAttributes):
7067
self.id = self.savedAttributes["id"]
7168
if self.savedAttributes["root"]:
7269
return
73-
if self.savedAttributes["checked"] == True:
70+
if self.savedAttributes["checked"]:
7471
self.setCheckState(0, Qt.Checked)
7572
else:
7673
self.setCheckState(0, Qt.Unchecked)
@@ -179,7 +176,7 @@ def getLayerTreeChanges(self):
179176
treeitem.updateNewAttributes()
180177
change = treeitem.getItemChange()
181178
if change is not None:
182-
if not "id" in change:
179+
if "id" not in change:
183180
allChanges["newItems"].append(change)
184181
else:
185182
allChanges["changeItems"].append(change)
@@ -388,13 +385,13 @@ def setupUi(self):
388385
self.tabWidget.addTab(t, tab[0])
389386

390387
for label in tab[1]:
391-
l = QtGui.QLabel(t)
392-
l.setText(label[0])
393-
l.setGeometry(QRect(label[1][0], label[1][1], label[1][2], label[1][3]))
388+
l2 = QtGui.QLabel(t)
389+
l2.setText(label[0])
390+
l2.setGeometry(QRect(label[1][0], label[1][1], label[1][2], label[1][3]))
394391
if tab[0] == "Layer":
395392
font = QFont("Arial", 12)
396393
font.setBold(True)
397-
l.setFont(font)
394+
l2.setFont(font)
398395

399396
self.tabWidget.setCurrentIndex(0)
400397

gui/dialog_bases/connectdlg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
This code is licensed under the GPL 2.0 license.
55
"""
66

7-
__author__ = "ntreff"
8-
__date__ = "July 2025"
9-
107
import sys
118

129
if sys.version_info[0] >= 3:
@@ -16,6 +13,9 @@
1613
from PyQt4.QtCore import QRect
1714
from PyQt4.QtGui import QDialog, QLabel, QLineEdit, QPushButton
1815

16+
__author__ = "ntreff"
17+
__date__ = "July 2025"
18+
1919

2020
class ConnectDialog(QDialog):
2121
def __init__(self):

gui/dialog_bases/dockwidget.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
This code is licensed under the GPL 2.0 license.
55
"""
66

7-
__author__ = "ntreff"
8-
__date__ = "July 2025"
9-
107
import sys
118

129
if sys.version_info[0] >= 3:
@@ -16,6 +13,9 @@
1613
from PyQt4.QtCore import QRect, Qt
1714
from PyQt4.QtGui import QDockWidget, QPushButton, QTreeWidget, QWidget
1815

16+
__author__ = "ntreff"
17+
__date__ = "July 2025"
18+
1919

2020
class DockWidget(QDockWidget):
2121
def __init__(self):

gui/dialog_bases/layerSettings.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
This code is licensed under the GPL 2.0 license.
55
"""
66

7-
__author__ = "ntreff"
8-
__date__ = "July 2025"
9-
107
import sys
8+
from qgis.gui import QgsMapLayerComboBox
119

1210
if sys.version_info[0] >= 3:
1311
# we are faking the old way of QtGui, not the best style, but makes it easier
@@ -19,7 +17,8 @@
1917
from PyQt4.QtCore import QRect, Qt
2018
from PyQt4 import QtGui
2119

22-
from qgis.gui import QgsMapLayerComboBox
20+
__author__ = "ntreff"
21+
__date__ = "July 2025"
2322

2423

2524
class LayerSettingsDialog(QtGui.QDialog):
@@ -72,13 +71,13 @@ def setupUi(self):
7271
self.tabWidget.addTab(t, tab[0])
7372

7473
for label in tab[1]:
75-
l = QtGui.QLabel(t)
76-
l.setGeometry(QRect(label[1][0], label[1][1], label[1][2], label[1][3]))
74+
l2 = QtGui.QLabel(t)
75+
l2.setGeometry(QRect(label[1][0], label[1][1], label[1][2], label[1][3]))
7776
if label[0] == "explanation":
78-
l.setText(expl)
79-
l.setAlignment(Qt.AlignTop)
77+
l2.setText(expl)
78+
l2.setAlignment(Qt.AlignTop)
8079
else:
81-
l.setText(label[0])
80+
l2.setText(label[0])
8281

8382
self.tabWidget.setCurrentIndex(0)
8483

gui/editor.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@
44
This code is licensed under the GPL 2.0 license.
55
"""
66

7-
__author__ = "ntreff"
8-
__date__ = "July 2025"
9-
10-
import sys
11-
127
from qgis.core import QgsNetworkAccessManager
13-
from qgis.gui import QgsMessageBar
148
from qgis.PyQt.QtCore import QObject, Qt, QTimer
159
from qgis.PyQt.QtWidgets import QAction, QMenu, QMessageBox, QTreeWidgetItemIterator
16-
from qgis_shogun_editor_plugin.connection.shogunressource import ShogunRessource
1710

11+
from ..connection.shogunressource import ShogunRessource
1812
from .dialog_bases.connectdlg import ConnectDialog
1913
from .dialog_bases.dockwidget import DockWidget
20-
from .editoritems import EditorItem, EditorTopItem, QgisLayerItem, ApplicationItem, LayerItem
21-
from ..connection.shogunressource import ShogunRessource
14+
from .editoritems import ApplicationItem, EditorItem, EditorTopItem, LayerItem, QgisLayerItem
15+
16+
__author__ = "ntreff"
17+
__date__ = "July 2025"
2218

2319

2420
class Editor(QObject):
@@ -53,12 +49,13 @@ def __init__(self, iface):
5349
'authenticationRequired' (inherited from QNetworkAccessManager) to a
5450
method where a dialog in QGIS pops up asking for the users credentials
5551
(when working with Basic Auth). We disable the signal here as the
56-
case of wrong identifacation credentials is treated separately
52+
case of wrong identification credentials is treated separately
5753
in def: checkConnection(self)
5854
"""
5955
try:
6056
QgsNetworkAccessManager.instance().authenticationRequired.disconnect()
61-
except:
57+
except Exception as e:
58+
print('Error occurred: ' + str(e))
6259
pass
6360

6461
def on_context_menu(self, point):
@@ -138,7 +135,8 @@ def on_tree_item_double_clicked(self, item):
138135
if isinstance(item, QgisLayerItem):
139136
try:
140137
self.iface.showLayerProperties(item.layer)
141-
except:
138+
except Exception as e:
139+
print('Error occurred: ' + str(e))
142140
pass
143141

144142
def showDialog(self, item):
@@ -158,7 +156,8 @@ def showDialog(self, item):
158156
try:
159157
dialog.setWindowState(Qt.WindowActive)
160158
dialog.activateWindow()
161-
except:
159+
except Exception as e:
160+
print('Error occurred: ' + str(e))
162161
pass
163162

164163
def setupNewConnection(self):
@@ -175,7 +174,7 @@ def setupNewConnection(self):
175174
pw = self.connectdlg.passwordIn.text()
176175

177176
if len(url) == 0 or len(name) == 0:
178-
self.showWarning(self.connectdlg, "Please fill in all necessary " "fields")
177+
self.showWarning(self.connectdlg, "Please fill in all necessary fields")
179178
self.connectdlg.show()
180179
return
181180

@@ -195,10 +194,10 @@ def setupNewConnection(self):
195194
self.connectdlg.show()
196195
return
197196

198-
bool = newRessource.updateData()
199-
if not bool:
197+
result = newRessource.updateData()
198+
if not result:
200199
self.showWarning(
201-
self.connectdlg, "Error: Could not retrieve all " "data from Shogun"
200+
self.connectdlg, "Error: Could not retrieve all data from Shogun"
202201
)
203202

204203
self.connectdlg.hide()
@@ -223,7 +222,7 @@ def refreshConnection(self, item):
223222
self.expandEditorTree(item)
224223

225224
def showWarning(self, parent, text):
226-
warn = QMessageBox.warning(parent, "Warning", text, QMessageBox.Ok)
225+
QMessageBox.warning(parent, "Warning", text, QMessageBox.Ok)
227226

228227
def uploadStyle(self, item):
229228
success = item.uploadStyle()
@@ -249,9 +248,9 @@ def loadAllAppLayers(self, item):
249248
layer.addQgsLayer(self.iface)
250249

251250
def expandEditorTree(self, connectionItem):
252-
iter = QTreeWidgetItemIterator(connectionItem)
253-
val = iter.value()
251+
iterator = QTreeWidgetItemIterator(connectionItem)
252+
val = iterator.value()
254253
while val:
255254
val.setExpanded(True)
256-
iter += 1
257-
val = iter.value()
255+
iterator += 1
256+
val = iterator.value()

0 commit comments

Comments
 (0)