pep8: Some modifications to respect pep8 standard code.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-10-11 11:06:45 +02:00
1 parent 8544dd1144
commit fa2454d079
152 files changed
+1626 -1277

No files matched your search

+67 -63
View File
@@ -16,7 +16,8 @@
# -*- coding: utf-8 -*-
import os, sys
import os
import sys
import logging
import subprocess
from queue import Queue
@@ -107,6 +108,7 @@ action = (
no_model_action + model_action + define_model_action
)
class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def __init__(self, conf=None):
super(ApplicationWindow, self).__init__()
@@ -132,10 +134,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self.setup_sc()
self.setup_connection()
self.default_style()
self.setup_debug_mode(init = True)
self.setup_debug_mode(init=True)
self.trans = QTranslator(self)
#self.ui.retranslateUi()
# self.ui.retranslateUi()
if self.conf.last_study != "" and not self.conf.close_correctly:
self.dialog_reopen_study()
@@ -153,7 +155,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
title += "Pamhyr2"
self.setWindowTitle(title)
def enable_actions(self, action:str, enable:bool):
def enable_actions(self, action: str, enable: bool):
"""Enable of disable an action componant
Args:
@@ -196,7 +198,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
"action_menu_edit_reach_sediment_layers": self.open_reach_sediment_layers,
"action_menu_close": self.close_model,
"action_menu_results_last": self.open_last_results,
## Help
# Help
"action_menu_pamhyr_users_pdf": lambda: self.open_doc_user(ext="pdf"),
"action_menu_pamhyr_developers_pdf": lambda: self.open_doc_dev(ext="pdf"),
"action_menu_pamhyr_users_html": lambda: self.open_doc_user(ext="html"),
@@ -209,7 +211,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
"action_toolBar_save": self.save_study,
"action_toolBar_close": self.close_model,
"action_toolBar_run_solver": self.run_solver,
## Current actions
# Current actions
"action_toolBar_network": self.open_network,
"action_toolBar_geometry": self.open_geometry,
"action_toolBar_mesh": lambda: self.open_dummy("Mesh"),
@@ -255,7 +257,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def closeEvent(self, event):
if not self._close_question:
if self._study is not None and not self._study.is_saved:
if self.dialog_close(cancel = False):
if self.dialog_close(cancel=False):
# PAMHYR is close correctly (no crash)
self.conf.set_close_correctly()
super(ApplicationWindow, self).closeEvent(event)
@@ -272,7 +274,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
# Maximise window
self.showMaximized()
def set_debug_lvl(self, debug = True):
def set_debug_lvl(self, debug=True):
if debug:
logger.setLevel(logging.DEBUG)
logger.info("Set logging level to DEBUG")
@@ -280,7 +282,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
logger.setLevel(logging.INFO)
logger.info("Set logging level to INFO")
def setup_debug_mode(self, init = False):
def setup_debug_mode(self, init=False):
menu = self.findChild(QMenu, "menu_help")
self.set_title()
@@ -290,22 +292,23 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self.debug_action.triggered.connect(self.open_debug)
self.debug_sqlite_action = QAction("Debug SQLite", self)
self.debug_sqlite_action.setStatusTip("Open SQLite debuging tool (sqlitebrowser)")
self.debug_sqlite_action.setStatusTip(
"Open SQLite debuging tool (sqlitebrowser)")
self.debug_sqlite_action.triggered.connect(self.open_sqlite)
if self.conf.debug:
menu.addAction(self.debug_action)
menu.addAction(self.debug_sqlite_action)
self.set_debug_lvl(debug = True)
self.set_debug_lvl(debug=True)
else:
if self.conf.debug:
menu.addAction(self.debug_action)
menu.addAction(self.debug_sqlite_action)
self.set_debug_lvl(debug = True)
self.set_debug_lvl(debug=True)
else:
menu.removeAction(self.debug_action)
menu.removeAction(self.debug_sqlite_action)
self.set_debug_lvl(debug = False)
self.set_debug_lvl(debug=False)
#########
# MODEL #
@@ -430,7 +433,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
dlg.setWindowTitle("Last open study")
dlg.setText("Do you want to open again the last open study?")
opt = QMessageBox.Cancel | QMessageBox.Ok #| QMessageBox.Open
opt = QMessageBox.Cancel | QMessageBox.Ok # | QMessageBox.Open
dlg.setStandardButtons(opt)
dlg.setIcon(QMessageBox.Question)
@@ -446,7 +449,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
elif res == QMessageBox.Cancel:
return False
def dialog_close(self, cancel = True):
def dialog_close(self, cancel=True):
dlg = QMessageBox(self)
dlg.setWindowTitle("Close PAMHYR without saving study")
@@ -504,7 +507,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
dialog = QFileDialog(self)
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
dialog.setDefaultSuffix(".pamhyr")
#dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
dialog.setNameFilters(['PamHyr (*.pamhyr)'])
dialog.setDirectory(os.path.dirname(self.conf.last_study))
@@ -554,11 +557,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if (self._study is not None and self._study.river.has_current_reach()):
geometry = self.sub_win_filter_first(
"Geometry",
contain = [self._study.river.current_reach().name]
contain=[self._study.river.current_reach().name]
)
if geometry is None:
geometry = GeometryWindow(study=self._study, config=self.conf, parent=self)
geometry = GeometryWindow(
study=self._study, config=self.conf, parent=self)
geometry.show()
else:
geometry.activateWindow()
@@ -568,11 +572,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_boundary_cond(self):
bound = self.sub_win_filter_first(
"Boundary conditions",
contain = []
contain=[]
)
if bound is None:
bound = BoundaryConditionWindow(study = self._study, parent = self)
bound = BoundaryConditionWindow(study=self._study, parent=self)
bound.show()
else:
bound.activateWindow()
@@ -580,11 +584,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_lateral_contrib(self):
lateral = self.sub_win_filter_first(
"Lateral contribution",
contain = []
contain=[]
)
if lateral is None:
lateral = LateralContributionWindow(study = self._study, parent = self)
lateral = LateralContributionWindow(study=self._study, parent=self)
lateral.show()
else:
lateral.activateWindow()
@@ -592,14 +596,14 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_stricklers(self):
strick = self.sub_win_filter_first(
"Stricklers",
contain = []
contain=[]
)
if strick is None:
strick = StricklersWindow(
study = self._study,
config = self.conf,
parent = self
study=self._study,
config=self.conf,
parent=self
)
strick.show()
else:
@@ -607,17 +611,17 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_frictions(self):
if (self._study is not None and
self._study.river.has_current_reach()):
self._study.river.has_current_reach()):
frictions = self.sub_win_filter_first(
"Frictions",
contain = [self._study.river.current_reach().name]
contain=[self._study.river.current_reach().name]
)
if frictions is None:
frictions = FrictionsWindow(
study = self._study,
parent = self
study=self._study,
parent=self
)
frictions.show()
else:
@@ -629,14 +633,14 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if self._study.river.has_current_reach():
initial = self.sub_win_filter_first(
"Initial condition",
contain = [self._study.river.current_reach().name]
contain=[self._study.river.current_reach().name]
)
if initial is None:
initial = InitialConditionsWindow(
study = self._study,
config = self.conf,
parent = self
study=self._study,
config=self.conf,
parent=self
)
initial.show()
else:
@@ -647,13 +651,13 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_solver_parameters(self):
params = self.sub_win_filter_first(
"Solver parameters",
contain = []
contain=[]
)
if params is None:
params = SolverParametersWindow(
study = self._study,
parent = self
study=self._study,
parent=self
)
params.show()
else:
@@ -661,15 +665,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_sediment_layers(self):
sl = SedimentLayersWindow(
study = self._study,
parent = self
study=self._study,
parent=self
)
sl.show()
def open_reach_sediment_layers(self):
sl = ReachSedimentLayersWindow(
study = self._study,
parent = self
study=self._study,
parent=self
)
sl.show()
@@ -678,30 +682,30 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
return
run = SelectSolverWindow(
study = self._study,
config = self.conf,
parent = self
study=self._study,
config=self.conf,
parent=self
)
if run.exec():
solver = run.solver
check = CheckListWindow(
study = self._study,
config = self.conf,
solver = solver,
parent = self
study=self._study,
config=self.conf,
solver=solver,
parent=self
)
check.show()
def solver_log(self, solver):
sol = SolverLogWindow(
study = self._study,
config = self.conf,
solver = solver,
parent = self
study=self._study,
config=self.conf,
solver=solver,
parent=self
)
sol.show()
def open_solver_results(self, solver, results = None):
def open_solver_results(self, solver, results=None):
# If no specific results, get last results
if results is None:
results = self._last_results
@@ -713,15 +717,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
# Windows already opened
res = self.sub_win_filter_first(
"Results",
contain = [solver.name, results.date]
contain=[solver.name, results.date]
)
if res is None:
res = ResultsWindow(
study = self._study,
solver = solver,
results = results,
parent = self
study=self._study,
solver=solver,
results=results,
parent=self
)
res.show()
else:
@@ -763,8 +767,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
QDesktopServices.openUrl(url)
else:
doc = DocWindow(
filename = filename,
parent = self
filename=filename,
parent=self
)
doc.show()
@@ -783,9 +787,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_debug(self):
repl = ReplWindow(
study = self._study,
config = self.conf,
parent = self
study=self._study,
config=self.conf,
parent=self
)
repl.show()