diff --git a/src/View/BoundaryCondition/Edit/Plot.py b/src/View/BoundaryCondition/Edit/Plot.py index 3c1b880837ac41d5d7a51a4464fbdf7236521467..bb7a339c0e9600662665308f68424263ff02fb16 100644 --- a/src/View/BoundaryCondition/Edit/Plot.py +++ b/src/View/BoundaryCondition/Edit/Plot.py @@ -128,7 +128,7 @@ class Plot(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/BoundaryCondition/Table.py b/src/View/BoundaryCondition/Table.py index 3a5afd8fbe9be31e5a299bc04536c5f2d6e6fb4b..8aa1a3438cc9030944cf10dc97616dc21d03d5a7 100644 --- a/src/View/BoundaryCondition/Table.py +++ b/src/View/BoundaryCondition/Table.py @@ -54,7 +54,8 @@ _translate = QCoreApplication.translate class ComboBoxDelegate(QItemDelegate): - def __init__(self, data=None, mode="type", tab="", trad=None, parent=None): + def __init__(self, data=None, mode="type", tab="", + trad=None, parent=None): super(ComboBoxDelegate, self).__init__(parent) self._data = data @@ -103,8 +104,9 @@ class ComboBoxDelegate(QItemDelegate): def updateEditorGeometry(self, editor, option, index): r = QRect(option.rect) - if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: - r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) + if self.editor.windowFlags() & Qt.Popup: + if editor.parent() is not None: + r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) editor.setGeometry(r) @pyqtSlot() diff --git a/src/View/CheckList/Window.py b/src/View/CheckList/Window.py index 1e8fb5d445cda7fa80c008df0093eefaaa8c6bf3..0004f3e9399886b290ebb9baf42224b145f0681d 100644 --- a/src/View/CheckList/Window.py +++ b/src/View/CheckList/Window.py @@ -97,7 +97,8 @@ class CheckListWindow(PamhyrWindow): def setup_connections(self): self.find(QPushButton, "pushButton_ok").clicked.connect(self.accept) self.find(QPushButton, "pushButton_retry").clicked.connect(self.retry) - self.find(QPushButton, "pushButton_cancel").clicked.connect(self.reject) + self.find(QPushButton, "pushButton_cancel")\ + .clicked.connect(self.reject) def setup_thread(self): self._worker = Worker(self._study, self._checker_list) diff --git a/src/View/Frictions/PlotStricklers.py b/src/View/Frictions/PlotStricklers.py index 89fe50f876f5ba6e9c8badb93bde836882c856f9..a65ae896bdbe8b7969169521b14aaa966c2867ab 100644 --- a/src/View/Frictions/PlotStricklers.py +++ b/src/View/Frictions/PlotStricklers.py @@ -108,6 +108,6 @@ class PlotStricklers(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/Frictions/Table.py b/src/View/Frictions/Table.py index 1cf3dcc16b6444f64bb10bb568d8f8de1b134d64..e1678fdc55b684a800b698a7b7d09266272778d9 100644 --- a/src/View/Frictions/Table.py +++ b/src/View/Frictions/Table.py @@ -51,7 +51,8 @@ _translate = QCoreApplication.translate class ComboBoxDelegate(QItemDelegate): - def __init__(self, data=None, study=None, mode="stricklers", parent=None): + def __init__(self, data=None, study=None, + mode="stricklers", parent=None): super(ComboBoxDelegate, self).__init__(parent) self._data = data @@ -87,8 +88,9 @@ class ComboBoxDelegate(QItemDelegate): def updateEditorGeometry(self, editor, option, index): r = QRect(option.rect) - if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: - r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) + if self.editor.windowFlags() & Qt.Popup: + if editor.parent() is not None: + r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) editor.setGeometry(r) @pyqtSlot() @@ -116,12 +118,12 @@ class TableModel(PamhyrTableModel): return self._lst.get(row).end_kp elif self._headers[column] == "begin_strickler": value = self._lst.get(row).begin_strickler - if value == None: + if value is None: return _translate("Frictions", "Not defined") return str(value) elif self._headers[column] == "end_strickler": value = self._lst.get(row).end_strickler - if value == None: + if value is None: return _translate("Frictions", "Not defined") return str(value) diff --git a/src/View/Geometry/PlotAC.py b/src/View/Geometry/PlotAC.py index b67394c297a075643d94b66500f018f005684da7..1d7bf8d84fde42d1af4d90f619501b949b261d42 100644 --- a/src/View/Geometry/PlotAC.py +++ b/src/View/Geometry/PlotAC.py @@ -323,7 +323,7 @@ class PlotAC(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/Geometry/PlotKPZ.py b/src/View/Geometry/PlotKPZ.py index 983cc79807ce89caf649ac5d446a0bf2a6114226..41b08a8f074fa05888db408dc32bf1d0b9e6d408 100644 --- a/src/View/Geometry/PlotKPZ.py +++ b/src/View/Geometry/PlotKPZ.py @@ -170,7 +170,7 @@ class PlotKPZ(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/Geometry/PlotXY.py b/src/View/Geometry/PlotXY.py index 8c0edcbedbd2e7f3bed9d792364152451aaf4494..a851cc82c999dfc54004d343378b95a202088658 100644 --- a/src/View/Geometry/PlotXY.py +++ b/src/View/Geometry/PlotXY.py @@ -141,7 +141,7 @@ class PlotXY(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return @@ -191,8 +191,10 @@ class PlotXY(PamhyrPlot): self.after_plot_selected.set_visible(False) if 0 <= before < self.data.number_profiles: - self.before_plot_selected.set_data(self.data.profile(before).x(), - self.data.profile(before).y()) + self.before_plot_selected.set_data( + self.data.profile(before).x(), + self.data.profile(before).y() + ) self.before_plot_selected.set_visible(True) if 0 <= ind < self.data.number_profiles: @@ -201,8 +203,10 @@ class PlotXY(PamhyrPlot): self.plot_selected.set_visible(True) if 0 <= after < self.data.number_profiles: - self.after_plot_selected.set_data(self.data.profile(after).x(), - self.data.profile(after).y()) + self.after_plot_selected.set_data( + self.data.profile(after).x(), + self.data.profile(after).y() + ) self.after_plot_selected.set_visible(True) self.canvas.axes.relim() diff --git a/src/View/Geometry/Profile/Table.py b/src/View/Geometry/Profile/Table.py index d1a670ac1f468bf70c5c1cd198b083707389756c..9c8e7868f20f711cefbe5448dcb881767621f7e2 100644 --- a/src/View/Geometry/Profile/Table.py +++ b/src/View/Geometry/Profile/Table.py @@ -106,9 +106,13 @@ class GeometryProfileTableModel(PamhyrTableModel): if role == Qt.ToolTipRole: if value.strip().upper() == "RG": - return _translate("MainWindowProfile", "Rive gauche") + return _translate( + "MainWindowProfile", "Rive gauche" + ) else: - return _translate("MainWindowProfile", "Rive droite") + return _translate( + "MainWindowProfile", "Rive droite" + ) return QVariant() diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 201d6d3eb5823d0a7ded9dd2254ca4e06f892958..eca958b454bf5046a939c5f40a134600851ae4f2 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -139,7 +139,9 @@ class GeometryWindow(PamhyrWindow): name = profile.name + " " + str(profile.kp) return ( - f"<font color=\"Grey\">{self._trad['reach']}: {self._reach.name}" + " - " + "<font color=\"Grey\">" + + f"{self._trad['reach']}: {self._reach.name}" + + " - " + f"{self._trad['cross_section']}:</font> {name}" ) diff --git a/src/View/InitialConditions/PlotDKP.py b/src/View/InitialConditions/PlotDKP.py index ccb774da4f3b5dca225f2fa77ca0001c9697837f..b81e4cdfd139556daf574d83783b6a6f53d88a4d 100644 --- a/src/View/InitialConditions/PlotDKP.py +++ b/src/View/InitialConditions/PlotDKP.py @@ -74,6 +74,6 @@ class PlotDKP(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/InitialConditions/PlotDischarge.py b/src/View/InitialConditions/PlotDischarge.py index d2635a6ae80b59aa72f91ceeb246097332ef9f86..0f918501e15ca45b93024524deec2beedc9b5448 100644 --- a/src/View/InitialConditions/PlotDischarge.py +++ b/src/View/InitialConditions/PlotDischarge.py @@ -62,6 +62,6 @@ class PlotDischarge(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/InitialConditions/Table.py b/src/View/InitialConditions/Table.py index d9546a4974f814ffe5e690a2900cde141d6e0bfa..aef6a99280f5cb4c442bf16c7f333d802678fb9b 100644 --- a/src/View/InitialConditions/Table.py +++ b/src/View/InitialConditions/Table.py @@ -79,8 +79,9 @@ class ComboBoxDelegate(QItemDelegate): def updateEditorGeometry(self, editor, option, index): r = QRect(option.rect) - if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: - r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) + if self.editor.windowFlags() & Qt.Popup: + if editor.parent() is not None: + r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) editor.setGeometry(r) @pyqtSlot() diff --git a/src/View/InitialConditions/Window.py b/src/View/InitialConditions/Window.py index 5f270599e93e7758ac0bca0a70ee717f9cb1dda0..6fb29ca2d2d4ecad81a6ff3a3bb7a0f28586a7fa 100644 --- a/src/View/InitialConditions/Window.py +++ b/src/View/InitialConditions/Window.py @@ -45,7 +45,9 @@ from View.InitialConditions.UndoCommand import ( DuplicateCommand, ) -from View.InitialConditions.Table import InitialConditionTableModel, ComboBoxDelegate +from View.InitialConditions.Table import ( + InitialConditionTableModel, ComboBoxDelegate, +) from View.Tools.Plot.PamhyrCanvas import MplCanvas from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar diff --git a/src/View/LateralContribution/Edit/Plot.py b/src/View/LateralContribution/Edit/Plot.py index 336b154b9e940a602e43aa0cdc15a6bf70d6c5b9..c7e95caa2f7c8c224b5725c3501308926e814fc3 100644 --- a/src/View/LateralContribution/Edit/Plot.py +++ b/src/View/LateralContribution/Edit/Plot.py @@ -124,7 +124,7 @@ class Plot(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/LateralContribution/Edit/Window.py b/src/View/LateralContribution/Edit/Window.py index c5d12a380e1598283137d69e3faa46d58ea6ff6f..c813a3a9d76b169199ad246d3898bc4e3006f042 100644 --- a/src/View/LateralContribution/Edit/Window.py +++ b/src/View/LateralContribution/Edit/Window.py @@ -59,12 +59,14 @@ class EditLateralContributionWindow(PamhyrWindow): name = self._pamhyr_name if self._data is not None: edge_name = (self._data.edge.name if self._data.edge is not None - else _translate("LateralContribution", "Not associate")) + else _translate("LateralContribution", + "Not associate")) name = ( _translate("Edit lateral contribution", self._pamhyr_name) + f" - {study.name} " + f" - {self._data.name} ({self._data.id}) " + - f"({trad.get_dict('long_types')[self._data.lctype]} - {edge_name})" + f"({trad.get_dict('long_types')[self._data.lctype]} - " + + f"{edge_name})" ) super(EditLateralContributionWindow, self).__init__( diff --git a/src/View/LateralContribution/Table.py b/src/View/LateralContribution/Table.py index 95d09c9c1093b5c1992bae167528ddda94409ed7..060ca8cf78668b472a540deebeb1de632397e176 100644 --- a/src/View/LateralContribution/Table.py +++ b/src/View/LateralContribution/Table.py @@ -54,7 +54,8 @@ _translate = QCoreApplication.translate class ComboBoxDelegate(QItemDelegate): - def __init__(self, data=None, mode="type", tab="", trad=None, parent=None): + def __init__(self, data=None, mode="type", tab="", + trad=None, parent=None): super(ComboBoxDelegate, self).__init__(parent) self._data = data @@ -98,8 +99,9 @@ class ComboBoxDelegate(QItemDelegate): def updateEditorGeometry(self, editor, option, index): r = QRect(option.rect) - if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: - r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) + if self.editor.windowFlags() & Qt.Popup: + if editor.parent() is not None: + r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) editor.setGeometry(r) @pyqtSlot() diff --git a/src/View/LateralContribution/UndoCommand.py b/src/View/LateralContribution/UndoCommand.py index 198fd9593ec8d07f0e003edf79d0f42b9dc7aa2a..382ae1ac36aa1876e0264a57d3160eab84e3e7f5 100644 --- a/src/View/LateralContribution/UndoCommand.py +++ b/src/View/LateralContribution/UndoCommand.py @@ -24,7 +24,9 @@ from PyQt5.QtWidgets import ( ) from Model.LateralContribution.LateralContribution import LateralContribution -from Model.LateralContribution.LateralContributionList import LateralContributionList +from Model.LateralContribution.LateralContributionList import ( + LateralContributionList +) class SetNameCommand(QUndoCommand): diff --git a/src/View/RunSolver/Window.py b/src/View/RunSolver/Window.py index 2adfce60b4a6829f08b1fa6aad35a822221303d6..dcf39b5cd2c7aaf4c9ec863411fe97509263f612 100644 --- a/src/View/RunSolver/Window.py +++ b/src/View/RunSolver/Window.py @@ -48,7 +48,7 @@ from View.RunSolver.Log.Window import SolverLogFileWindow try: from signal import SIGTERM, SIGSTOP, SIGCONT _signal = True -except: +except Exception: _signal = False _translate = QCoreApplication.translate @@ -83,7 +83,8 @@ class SelectSolverWindow(PamhyrDialog): def setup_connections(self): self.find(QPushButton, "pushButton_run").clicked.connect(self.accept) - self.find(QPushButton, "pushButton_cancel").clicked.connect(self.reject) + self.find(QPushButton, "pushButton_cancel")\ + .clicked.connect(self.reject) @property def solver(self): @@ -181,7 +182,7 @@ class SolverLogWindow(PamhyrWindow): self._alarm.timeout.connect(self.update) def _log(self, msg, color=None): - if type(msg) == str: + if msg is str: msg = msg.rsplit('\n')[0] if color is not None: @@ -189,7 +190,7 @@ class SolverLogWindow(PamhyrWindow): self.find(QTextEdit, "textEdit").append(msg) - elif type(msg) == int: + elif msg is int: color = "blue" if msg == 0 else "red" self.find(QTextEdit, "textEdit")\ .append(f"<font color=\"{color}\">" + diff --git a/src/View/SedimentLayers/Edit/Plot.py b/src/View/SedimentLayers/Edit/Plot.py index 9a9baed3ac6b1c9b1ef905fbeef49632107cee82..87cfe6448bf58a69109a5f753d31449ad97e6e2a 100644 --- a/src/View/SedimentLayers/Edit/Plot.py +++ b/src/View/SedimentLayers/Edit/Plot.py @@ -11,8 +11,9 @@ logger = logging.getLogger() class Plot(PamhyrPlot): - def __init__(self, canvas=None, trad=None, data=None, toolbar=None, - display_current=True, parent=None): + def __init__(self, canvas=None, trad=None, data=None, + toolbar=None, display_current=True, + parent=None): super(Plot, self).__init__( canvas=canvas, trad=trad, @@ -88,7 +89,7 @@ class Plot(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/SedimentLayers/Edit/translate.py b/src/View/SedimentLayers/Edit/translate.py index ce036b8d6cb4bd62f38398f42bb734dbe78737f7..8c174ea39bb7f98d670e495b46090519c67ed27f 100644 --- a/src/View/SedimentLayers/Edit/translate.py +++ b/src/View/SedimentLayers/Edit/translate.py @@ -19,5 +19,6 @@ class SedimentEditTranslate(SedimentTranslate): "height": _translate("SedimentLayers", "Height"), "d50": _translate("SedimentLayers", "D50"), "sigma": _translate("SedimentLayers", "Sigma"), - "critical_constraint": _translate("SedimentLayers", "Critical constraint"), + "critical_constraint": _translate("SedimentLayers", + "Critical constraint"), } diff --git a/src/View/SedimentLayers/Reach/Plot.py b/src/View/SedimentLayers/Reach/Plot.py index 0db3b4e2efdff63036c55797be126f47b6736ac7..3664081cfb22f997ed4e0492c14a8d0d379406f0 100644 --- a/src/View/SedimentLayers/Reach/Plot.py +++ b/src/View/SedimentLayers/Reach/Plot.py @@ -91,7 +91,7 @@ class Plot(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/SedimentLayers/Reach/Profile/Plot.py b/src/View/SedimentLayers/Reach/Profile/Plot.py index 062070acbf0fabb291a3c320c0deecc533da2366..38adb990e0ddaa596abb1afb2afc4afcf33d26e1 100644 --- a/src/View/SedimentLayers/Reach/Profile/Plot.py +++ b/src/View/SedimentLayers/Reach/Profile/Plot.py @@ -90,7 +90,7 @@ class Plot(PamhyrPlot): @timer def update(self, ind=None): - if self._init == False: + if not self._init: self.draw() return diff --git a/src/View/SedimentLayers/Reach/Profile/Table.py b/src/View/SedimentLayers/Reach/Profile/Table.py index fbdfb0420aeb9190eb92e492390f903ed0200894..3754aa82bc09bb7ddf30a7d566491701cea4261d 100644 --- a/src/View/SedimentLayers/Reach/Profile/Table.py +++ b/src/View/SedimentLayers/Reach/Profile/Table.py @@ -61,8 +61,9 @@ class ComboBoxDelegate(QItemDelegate): def updateEditorGeometry(self, editor, option, index): r = QRect(option.rect) - if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: - r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) + if self.editor.windowFlags() & Qt.Popup: + if editor.parent() is not None: + r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) editor.setGeometry(r) @pyqtSlot() @@ -86,7 +87,7 @@ class TableModel(PamhyrTableModel): return self._data.point(row).name elif self._headers[column] == "sl": value = self._data.point(row).sl - if value == None: + if value is None: text = _translate("SedimentLayers", "Not defined") return text return str(value) diff --git a/src/View/SedimentLayers/Reach/Profile/Window.py b/src/View/SedimentLayers/Reach/Profile/Window.py index 1dcbd0a8077aa21af3ca0e8e7669d62d17bdce56..22ca8fcbd2e410acdba097b5403d7bfd961b7aee 100644 --- a/src/View/SedimentLayers/Reach/Profile/Window.py +++ b/src/View/SedimentLayers/Reach/Profile/Window.py @@ -30,7 +30,9 @@ from View.SedimentLayers.Reach.Profile.Plot import Plot from View.Tools.Plot.PamhyrCanvas import MplCanvas from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar -from View.SedimentLayers.Reach.Profile.translate import SedimentProfileTranslate +from View.SedimentLayers.Reach.Profile.translate import ( + SedimentProfileTranslate +) from View.SedimentLayers.Window import SedimentLayersWindow _translate = QCoreApplication.translate diff --git a/src/View/SedimentLayers/Reach/Table.py b/src/View/SedimentLayers/Reach/Table.py index 7e38fcc86317ff66991bfd68cc18d806a5fe54b7..7188940814fb6ed97aea9bf9cf303e8bb6e19b41 100644 --- a/src/View/SedimentLayers/Reach/Table.py +++ b/src/View/SedimentLayers/Reach/Table.py @@ -61,8 +61,9 @@ class ComboBoxDelegate(QItemDelegate): def updateEditorGeometry(self, editor, option, index): r = QRect(option.rect) - if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: - r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) + if self.editor.windowFlags() & Qt.Popup: + if editor.parent() is not None: + r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) editor.setGeometry(r) @pyqtSlot() @@ -88,7 +89,7 @@ class TableModel(PamhyrTableModel): return self._data.profile(row).kp if self._headers[column] == "sl": value = self._data.profile(row).sl - if value == None: + if value is None: text = _translate("SedimentLayers", "Not defined") return text return str(value) diff --git a/src/View/SedimentLayers/Reach/Window.py b/src/View/SedimentLayers/Reach/Window.py index 9c400909330a072ee55aee09cf867f23e996501d..6c4cad968efd2cd829cd95b3af9eb646b230ac8b 100644 --- a/src/View/SedimentLayers/Reach/Window.py +++ b/src/View/SedimentLayers/Reach/Window.py @@ -33,7 +33,9 @@ from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar from View.SedimentLayers.Reach.translate import SedimentReachTranslate from View.SedimentLayers.Window import SedimentLayersWindow -from View.SedimentLayers.Reach.Profile.Window import ProfileSedimentLayersWindow +from View.SedimentLayers.Reach.Profile.Window import ( + ProfileSedimentLayersWindow +) _translate = QCoreApplication.translate diff --git a/src/View/Stricklers/UndoCommand.py b/src/View/Stricklers/UndoCommand.py index 00aedb219ea64a76728d7214dcc33b07a5c044ef..b543b046f736e700c1f81aab79e86c03997c6cbb 100644 --- a/src/View/Stricklers/UndoCommand.py +++ b/src/View/Stricklers/UndoCommand.py @@ -24,7 +24,9 @@ from PyQt5.QtWidgets import ( ) from Model.LateralContribution.LateralContribution import LateralContribution -from Model.LateralContribution.LateralContributionList import LateralContributionList +from Model.LateralContribution.LateralContributionList import ( + LateralContributionList +) class SetNameCommand(QUndoCommand): diff --git a/src/View/Tools/ASubWindow.py b/src/View/Tools/ASubWindow.py index aa95ddcd78ac2cfd849430a6433e0648ce5aa722..a2e8fc88baa3b4de0c63c43daa84469f37d21d58 100644 --- a/src/View/Tools/ASubWindow.py +++ b/src/View/Tools/ASubWindow.py @@ -70,8 +70,8 @@ class WindowToolKit(object): stream = StringIO(data) rows = csv.reader(stream, delimiter='\t') - for l, row in enumerate(rows): - if has_header and l == 0: + for ind, row in enumerate(rows): + if has_header and ind == 0: header = row.copy() continue @@ -79,7 +79,9 @@ class WindowToolKit(object): return header, values - def file_dialog(self, select_file=True, callback=lambda x: None, directory=None): + def file_dialog(self, select_file=True, + callback=lambda x: None, + directory=None): """Open a new file dialog and send result to callback function Args: diff --git a/src/View/Tools/ListedSubWindow.py b/src/View/Tools/ListedSubWindow.py index 5a6c132c929adc38febbb6675747534daec0840f..b548cb315d4d20e0bbd1226e2d4b6a40410a540f 100644 --- a/src/View/Tools/ListedSubWindow.py +++ b/src/View/Tools/ListedSubWindow.py @@ -40,7 +40,7 @@ class ListedSubWindow(object): try: logger.info( f"Open window: {name}: {self.sub_win_cnt}: {win.hash()}") - except: + except Exception: logger.info(f"Open window: {name}: {self.sub_win_cnt}: X") def sub_win_del(self, name): @@ -98,5 +98,5 @@ class ListedSubWindow(object): self.sub_win_list, ) )[1] - except: + except Exception: return None diff --git a/src/View/Tools/PamhyrDelegate.py b/src/View/Tools/PamhyrDelegate.py index c253ec25a81132fff8d84d1465baa9466fa78a30..9d68c90828a3d25692bf4f3a1855bc16e4f3d0e4 100644 --- a/src/View/Tools/PamhyrDelegate.py +++ b/src/View/Tools/PamhyrDelegate.py @@ -62,8 +62,9 @@ class PamhyrExTimeDelegate(QItemDelegate): def updateEditorGeometry(self, editor, option, index): r = QRect(option.rect) - if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: - r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) + if self.editor.windowFlags() & Qt.Popup: + if editor.parent() is not None: + r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) editor.setGeometry(r) @pyqtSlot() diff --git a/src/View/Tools/PamhyrTable.py b/src/View/Tools/PamhyrTable.py index ff815624f52756736f3c855a38fac430b6dedb4e..b77e26b9ceab0afe487e1b83caaf28fd1a5af4dd 100644 --- a/src/View/Tools/PamhyrTable.py +++ b/src/View/Tools/PamhyrTable.py @@ -109,7 +109,8 @@ class PamhyrTableModel(QAbstractTableModel): def _table_view_configure(self): self._table_view.setModel(self) self._table_view.setSelectionBehavior(QAbstractItemView.SelectRows) - self._table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) + self._table_view.horizontalHeader()\ + .setSectionResizeMode(QHeaderView.Stretch) self._table_view.setAlternatingRowColors(True) self._table_view.resizeColumnsToContents() @@ -131,8 +132,9 @@ class PamhyrTableModel(QAbstractTableModel): return len(self._headers) def headerData(self, section, orientation, role): - if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal: - return self._table_headers[self._headers[section]] + if role == Qt.ItemDataRole.DisplayRole: + if orientation == Qt.Orientation.Horizontal: + return self._table_headers[self._headers[section]] return QVariant() diff --git a/src/View/Tools/Plot/OnPickEvent.py b/src/View/Tools/Plot/OnPickEvent.py index e02c897dae027286f0443edc79ee5ff8c3cb8f18..87ab07588d3f06e53768921a8be5b0d74a753288 100644 --- a/src/View/Tools/Plot/OnPickEvent.py +++ b/src/View/Tools/Plot/OnPickEvent.py @@ -75,8 +75,11 @@ class OnpickEvent(object): def select_row_pt_clicked(self, ind: int = 0): """ Args: - ind: Indice de la ligne où se trouve le point le plus proche 'visé'. - Returns: Sélectionne la ligne (du tableau) correspondant au point le plus proche 'visé' à la suite de l'événement onpick. + ind: Indice de la ligne où se trouve le point le plus proche + 'visé'. + + Returns: Sélectionne la ligne (du tableau) correspondant au point le + plus proche 'visé' à la suite de l'événement onpick. """ if self.tableView is not None: selectionModel = self.tableView.selectionModel() @@ -98,7 +101,8 @@ class OnpickEvent(object): def select_point_plot(self): """ - Returns: sélectionne le(s) point(s) du graphique correspondant à la/aux ligne(s) sélectionnée(s) dans le tableau. + Returns: sélectionne le(s) point(s) du graphique correspondant à + la/aux ligne(s) sélectionnée(s) dans le tableau. """ if self.tableView is not None: rows = list(set( @@ -125,15 +129,17 @@ class OnpickEvent(object): try: [pl[0].set_data([], []) for pl in self.pt if len(self.pt) > 1] - except: + except Exception: logger.info("update_select_point_point: Update issue") try: self.update_select_point_point_bis(self.x[row], self.y[row]) - except: + except Exception: logger.info( - "update_select_point_point_bis: Update issue, possible index missing") + "update_select_point_point_bis: Update issue, " + + "possible index missing" + ) self.ax.figure.canvas.draw_idle() @@ -150,13 +156,18 @@ class OnpickEvent(object): def plot_selection_point(self, x, y): """ Args: - x: abscisse - y: ordonnée - Returns: sélectionne le point du graphique correspond à la ligne sélectionnée dans le tableau. + x: abscissa + y: ordinate + + Returns: sélectionne le point du graphique correspond à la ligne + sélectionnée dans le tableau. """ if self.tableView is not None: - self.select_point, = self.ax.plot(x, y, - '+', c='Blue', markersize=7) + self.select_point, = self.ax.plot( + x, y, + '+', c='Blue', + markersize=7 + ) else: self.select_point, = self.ax.plot([], []) @@ -210,7 +221,8 @@ class OnpickEvent(object): @property def delta_x(self): """" - Returns: la longueur entre les limites de la vue sur l'axe des x, c'est-à -dire |x_max_visible - x_min_visible|. + Returns: la longueur entre les limites de la vue sur l'axe des x, + c'est-à -dire |x_max_visible - x_min_visible|. """ xgauche, xdroite = self.ax.get_xlim() delta_x = abs(xdroite - xgauche) @@ -219,7 +231,8 @@ class OnpickEvent(object): @property def delta_y(self): """ - Returns: la longueur entre les limites de la vue sur l'axe des y, c'est à dire |y_max_visible - y_min_visible|. + Returns: la longueur entre les limites de la vue sur l'axe des y, + c'est à dire |y_max_visible - y_min_visible|. """ ybas, yhaut = self.ax.get_ylim() delta_y = abs(yhaut - ybas) @@ -229,8 +242,9 @@ class OnpickEvent(object): def indice_points_onpick(event): """ Args: event - Returns: le(s) indexe(s) du/des point(s) (plus précisement les coordonnées de points) capturé(s) - par l'événement onpick (voir picker) + Returns: le(s) indexe(s) du/des point(s) (plus précisement les + coordonnées de points) capturé(s) par l'événement onpick + (voir picker) """ return event.ind @@ -238,9 +252,9 @@ class OnpickEvent(object): """ Args: event: - Returns: une array contenant les coordonées des points qui se trouvent dans la zone définie par l'événement - onpick (voir picker) - + Returns: une array contenant les coordonées des points qui se + trouvent dans la zone définie par l'événement onpick + (voir picker) """ thisline = event.artist xdata = thisline.get_xdata() @@ -254,8 +268,9 @@ class OnpickEvent(object): """ Args: event: - Returns: la liste des distances normées (en m) entre les points situés dans la région définie par l'événement - onpick (voir picker). + Returns: la liste des distances normées (en m) entre les points + situés dans la région définie par l'événement onpick + (voir picker). """ ind = event.ind thisline = event.artist @@ -282,15 +297,23 @@ class OnpickEvent(object): """ Args: event: - Returns: la liste des distances 'visuelles' entre les points situés dans la région définie par l'événement - onpick (voir picker). + Returns: la liste des distances 'visuelles' entre les points situés + dans la région définie par l'événement onpick (voir picker). """ bbox = self.ax.get_window_extent()\ .transformed(self.ax.figure.dpi_scale_trans.inverted()) ratio_w_sur_h = bbox.width / bbox.height distances_ecran = [ - (((x - event.mouseevent.xdata) / (self.delta_x * ratio_w_sur_h)) ** 2 + - ((y - event.mouseevent.ydata) / self.delta_y) ** 2) ** (1 / 2) + ( + ( + (x - event.mouseevent.xdata) / + (self.delta_x * ratio_w_sur_h) + ) ** 2 + + ( + (y - event.mouseevent.ydata) / + self.delta_y + ) ** 2 + ) ** (1 / 2) for (x, y) in self.points_onpick(event) ] @@ -298,9 +321,11 @@ class OnpickEvent(object): def distances(self, event): """ - Args: event: - Returns: la liste des distances entre la position de la souris et tous les points se trouvant dans - la zone définie par l'événement onpick ( voir picker) + Args: + event: + Returns: la liste des distances entre la position de la souris et + tous les points se trouvant dans la zone définie par + l'événement onpick (voir picker) """ distances = np.linalg.norm( self.points_onpick(event) - self.position_souris(event), @@ -311,18 +336,23 @@ class OnpickEvent(object): def index_pt_plus_proche_ecran(self, event): """ - Args: - event: - Returns: indice du point le plus proche visuellement de la position du click. - """ + Args: + event: + Returns: indice du point le plus proche visuellement de la position + du click. + """ dataidx_ecran = np.argmin(self.distance_ecran(event)) return dataidx_ecran def point_plus_proche_ecran(self, event): point_onpick = self.points_onpick(event) - datapos_ecran = point_onpick[self.index_pt_plus_proche_ecran(event)] + datapos_ecran = point_onpick[ + self.index_pt_plus_proche_ecran(event) + ] - return self.points_onpick(event)[self.index_pt_plus_proche_ecran(event)] + return self.points_onpick(event)[ + self.index_pt_plus_proche_ecran(event) + ] def index_pt_plus_proche(self, event): """ @@ -408,8 +438,10 @@ class OnpickEvent(object): cte = event.y * 0.1 / 100 self.y_pos_text_param_hydrau = event.ydata + cte - self.annotation_onclick.set_position((self.pos_x_annotation, - self.y_pos_text_param_hydrau)) + self.annotation_onclick.set_position( + (self.pos_x_annotation, + self.y_pos_text_param_hydrau) + ) self.ax.callbacks.connect('ylim_changed', self.on_ylims_change) @@ -454,7 +486,7 @@ class OnpickEvent(object): try: self.poly_col_bis.remove() self.largeur_au_miroir(event) - except: + except Exception: self.largeur_au_miroir(event) self.annotate_onclick(event) @@ -477,7 +509,8 @@ class OnpickEvent(object): """ Args: val: Valeur de la cote Z à laquelle on veut caluler A , p et L. - Returns: la valeur de la section mouillée A, du périmètre mouillé p et de la largeur au miroir L. + Returns: la valeur de la section mouillée A, du périmètre mouillé p + et de la largeur au miroir L. """ largeur_miroir = 0. section_mouillee_totale = 0. @@ -495,7 +528,10 @@ class OnpickEvent(object): perimetre_shapely = 0. perim_calc = 0. - for polyg, coul in zip(liste_chemins, couleurs[0:len(liste_chemins)]): + for polyg, coul in zip( + liste_chemins, + couleurs[0:len(liste_chemins)] + ): points_polygone = polyg.vertices xs = points_polygone[:, 0] ys = points_polygone[:, 1] @@ -510,7 +546,9 @@ class OnpickEvent(object): polygone_shapely = ShapelyPolygon(points_polygone) aire_calculee_shapely = polygone_shapely.area perimetre_shapely = polygone_shapely.length - perimetre_mouille_total_shapely = polygone_shapely.length - largeur_miroir + perimetre_mouille_total_shapely = ( + polygone_shapely.length - largeur_miroir + ) liste_points_fond = [ (x, y) for (x, y) in zip(xs, ys) if not np.isclose(y, val) ] @@ -519,7 +557,9 @@ class OnpickEvent(object): perimetre = 0 aire = 0 - for un_point in liste_points_fond + [(min(liste_points_miroir), val)]: + for un_point in liste_points_fond + [ + (min(liste_points_miroir), val) + ]: x_pt_suivant, y_pt_suivant = un_point perimetre += ((x_pt_prec - x_pt_suivant) ** 2 + (y_pt_prec - y_pt_suivant) ** 2) ** (1 / 2) diff --git a/src/View/Tools/Plot/PamhyrToolbar.py b/src/View/Tools/Plot/PamhyrToolbar.py index 7d769d32b577c9aecb293939cf0729b906d5999a..977087d053f68342bc686e9ef592e06648d20bb2 100644 --- a/src/View/Tools/Plot/PamhyrToolbar.py +++ b/src/View/Tools/Plot/PamhyrToolbar.py @@ -39,7 +39,8 @@ class PamhyrPlotToolbar(NavigationToolbar2QT): """ isometric_signal = pyqtSignal(str) - def __init__(self, canvas, parent, items=["home", "move", "zoom", "save"]): + def __init__(self, canvas, parent, + items=["home", "move", "zoom", "save"]): """PamhyrPlotToolbar Args: @@ -57,12 +58,22 @@ class PamhyrPlotToolbar(NavigationToolbar2QT): if "home" in items: self.toolitems.append( - ('Home', _translate("Toolbar", 'Default view'), 'home', 'home')) + ( + 'Home', + _translate("Toolbar", 'Default view'), + 'home', 'home' + ) + ) self.toolitems.append((None, None, None, None)) if "back/forward" in items: self.toolitems.append( - ('Back', _translate("Toolbar", 'Back to previous view'), 'back', 'back')) + ( + 'Back', + _translate("Toolbar", 'Back to previous view'), + 'back', 'back' + ) + ) self.toolitems.append(('Forward', _translate( "Toolbar", 'Return to next view'), 'forward', 'forward')) self.toolitems.append((None, None, None, None)) @@ -77,7 +88,12 @@ class PamhyrPlotToolbar(NavigationToolbar2QT): if "zoom" in items: self.toolitems.append( - ('Zoom', _translate("Toolbar", 'Zoom'), 'zoom_to_rect', 'zoom')) + ( + 'Zoom', + _translate("Toolbar", 'Zoom'), + 'zoom_to_rect', 'zoom' + ) + ) self.toolitems.append((None, None, None, None)) icon_zoom = QtGui.QIcon() @@ -104,11 +120,21 @@ class PamhyrPlotToolbar(NavigationToolbar2QT): icon_btn_isometric_view = QtGui.QIcon() icon_btn_isometric_view.addPixmap( - QtGui.QPixmap(os.path.abspath(f"{file_path}/../ui/ressources/zoom_fit_11.png"))) + QtGui.QPixmap( + os.path.abspath( + f"{file_path}/../ui/ressources/zoom_fit_11.png" + ) + ) + ) icon_btn_global_view = QtGui.QIcon() icon_btn_global_view.addPixmap( - QtGui.QPixmap(os.path.abspath(f"{file_path}/../ui/ressources/zoom_fit.png"))) + QtGui.QPixmap( + os.path.abspath( + f"{file_path}/../ui/ressources/zoom_fit.png" + ) + ) + ) icons.append(("isometric_view", icon_btn_isometric_view)) icons.append(("non_isometric_view", icon_btn_global_view)) diff --git a/src/init.py b/src/init.py index 9a2305f4cdf011795e0f333fde40962c5a00cdcb..390725c7fd83ab619a14a60d56f7b7ecf1e7c051 100644 --- a/src/init.py +++ b/src/init.py @@ -63,13 +63,14 @@ def legal_info(): def blue(s): return logger.info( f"{logger_color_blue()}{s}{logger_color_reset()}") - blue("""`7MM\"""Mq. db `7MMM. ,MMF'`7MMF' `7MMF'`YMM' `MM'`7MM\"""Mq.""") - blue(""" MM `MM. ;MM: MMMb dPMM MM MM VMA ,V MM `MM.""") - blue(""" MM ,M9 ,V^MM. M YM ,M MM MM MM VMA ,V MM ,M9 pd*"*b.""") - blue(""" MMmmdM9 ,M `MM M Mb M' MM MMmmmmmmMM VMMP MMmmdM9 (O) j8""") - blue(""" MM AbmmmqMA M YM.P' MM MM MM MM MM YM. ,;j9""") - blue(""" MM A' VML M `YM' MM MM MM MM MM `Mb. ,-='""") - blue(""".JMML. .AMA. .AMMA..JML. `' .JMML..JMML. .JMML. .JMML. .JMML. .JMM. Ammmmmmm""") + with open(os.path.abspath( + os.path.join( + os.path.dirname(__file__), + "motd.txt" + ) + ), "r") as f: + for line in f: + blue(line.rstrip()) with open(os.path.abspath( os.path.join( diff --git a/src/motd.txt b/src/motd.txt new file mode 100644 index 0000000000000000000000000000000000000000..bfe03bf07c00fe5ae7fa8e3f2824b06dad3c01cc --- /dev/null +++ b/src/motd.txt @@ -0,0 +1,7 @@ +`7MM"""Mq. db `7MMM. ,MMF'`7MMF' `7MMF'`YMM' `MM'`7MM"""Mq. + MM `MM. ;MM: MMMb dPMM MM MM VMA ,V MM `MM. + MM ,M9 ,V^MM. M YM ,M MM MM MM VMA ,V MM ,M9 pd*"*b. + MMmmdM9 ,M `MM M Mb M' MM MMmmmmmmMM VMMP MMmmdM9 (O) j8 + MM AbmmmqMA M YM.P' MM MM MM MM MM YM. ,;j9 + MM A' VML M `YM' MM MM MM MM MM `Mb. ,-=' +.JMML. .AMA. .AMMA..JML. `' .JMML..JMML. .JMML. .JMML. .JMML. .JMM. Ammmmmmm