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

+10 -10
View File
@@ -29,16 +29,17 @@ from View.LateralContribution.Edit.translate import *
_translate = QCoreApplication.translate
class Plot(PamhyrPlot):
def __init__(self, mode = "time", data=None,
def __init__(self, mode="time", data=None,
canvas=None, trad=None, toolbar=None,
parent=None):
super(Plot, self).__init__(
canvas = canvas,
trad = trad,
data = data,
toolbar = toolbar,
parent = parent
canvas=canvas,
trad=trad,
data=data,
toolbar=toolbar,
parent=parent
)
self._table_headers = self._trad.get_dict("table_headers")
@@ -68,8 +69,8 @@ class Plot(PamhyrPlot):
map(
lambda v: str(
datetime.fromtimestamp(v[0]) - t0
).split(",")[0]\
.replace("days", _translate("LateralContribution", "days"))\
).split(",")[0]
.replace("days", _translate("LateralContribution", "days"))
.replace("day", _translate("LateralContribution", "day")),
fx
)
@@ -84,7 +85,6 @@ class Plot(PamhyrPlot):
self.canvas.axes.set_xticks(ticks=xx, labels=xt, rotation=45)
@timer
def draw(self):
self.canvas.axes.cla()
@@ -118,7 +118,7 @@ class Plot(PamhyrPlot):
self.canvas.axes.autoscale_view(True, True, True)
self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()
#self.toolbar.update()
# self.toolbar.update()
self._init = True
@@ -25,6 +25,7 @@ from PyQt5.QtWidgets import (
from Model.LateralContribution.LateralContribution import LateralContribution
class SetDataCommand(QUndoCommand):
def __init__(self, data, index, column, new_value):
QUndoCommand.__init__(self)
@@ -42,6 +43,7 @@ class SetDataCommand(QUndoCommand):
def redo(self):
self._data._set_i_c_v(self._index, self._column, self._new)
class AddCommand(QUndoCommand):
def __init__(self, data, index):
QUndoCommand.__init__(self)
@@ -59,6 +61,7 @@ class AddCommand(QUndoCommand):
else:
self._data.insert(self._index, self._new)
class DelCommand(QUndoCommand):
def __init__(self, data, rows):
QUndoCommand.__init__(self)
@@ -78,6 +81,7 @@ class DelCommand(QUndoCommand):
def redo(self):
self._data.delete_i(self._rows)
class SortCommand(QUndoCommand):
def __init__(self, data, _reverse):
QUndoCommand.__init__(self)
+23 -23
View File
@@ -45,6 +45,7 @@ from View.LateralContribution.Edit.Plot import Plot
_translate = QCoreApplication.translate
class EditLateralContributionWindow(PamhyrWindow):
_pamhyr_ui = "EditLateralContribution"
_pamhyr_name = "Edit lateral contribution"
@@ -67,11 +68,11 @@ class EditLateralContributionWindow(PamhyrWindow):
)
super(EditLateralContributionWindow, self).__init__(
title = name,
study = study,
config = config,
trad = trad,
parent = parent
title=name,
study=study,
config=config,
trad=trad,
parent=parent
)
self.setup_table()
@@ -80,9 +81,9 @@ class EditLateralContributionWindow(PamhyrWindow):
def setup_table(self):
self._delegate_time = PamhyrExTimeDelegate(
data = self._data,
mode = self._study.time_system,
parent = self
data=self._data,
mode=self._study.time_system,
parent=self
)
headers = {}
@@ -92,16 +93,16 @@ class EditLateralContributionWindow(PamhyrWindow):
table = self.find(QTableView, "tableView")
self._table = TableModel(
table_view = table,
table_headers = headers,
editable_headers = self._data.header,
delegates = {
table_view=table,
table_headers=headers,
editable_headers=self._data.header,
delegates={
"time": self._delegate_time,
},
data = self._data,
undo = self._undo_stack,
trad = self._trad,
opt_data = self._study.time_system
data=self._data,
undo=self._undo_stack,
trad=self._trad,
opt_data=self._study.time_system
)
table.setModel(self._table)
@@ -119,12 +120,12 @@ class EditLateralContributionWindow(PamhyrWindow):
self.verticalLayout.addWidget(self.canvas)
self.plot = Plot(
canvas = self.canvas,
data = self._data,
mode = self._study.time_system,
toolbar = self.toolbar,
trad = self._trad,
parent = self
canvas=self.canvas,
data=self._data,
mode=self._study.time_system,
toolbar=self.toolbar,
trad=self._trad,
parent=self
)
self.plot.draw()
@@ -156,7 +157,6 @@ class EditLateralContributionWindow(PamhyrWindow):
)
)
def add(self):
rows = self.index_selected_rows()
if len(self._data) == 0 or len(rows) == 0:
@@ -23,6 +23,7 @@ from View.LateralContribution.translate import LCTranslate
_translate = QCoreApplication.translate
class LCETranslate(LCTranslate):
def __init__(self):
super(LCETranslate, self).__init__()
+4 -2
View File
@@ -52,8 +52,9 @@ logger = logging.getLogger()
_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
@@ -154,7 +155,8 @@ class TableModel(PamhyrTableModel):
)
)
elif self._headers[column] == "type":
key = next(k for k, v in self._long_types.items() if v == value)
key = next(k for k, v in self._long_types.items()
if v == value)
self._undo.push(
SetTypeCommand(
self._lst, self._tab, row, LC_types[key]
@@ -26,6 +26,7 @@ from PyQt5.QtWidgets import (
from Model.LateralContribution.LateralContribution import LateralContribution
from Model.LateralContribution.LateralContributionList import LateralContributionList
class SetNameCommand(QUndoCommand):
def __init__(self, lcs, tab, index, new_value):
QUndoCommand.__init__(self)
@@ -42,6 +43,7 @@ class SetNameCommand(QUndoCommand):
def redo(self):
self._lcs.get(self._tab, self._index).name = self._new
class SetBeginCommand(QUndoCommand):
def __init__(self, lcs, tab, index, new_value):
QUndoCommand.__init__(self)
@@ -58,6 +60,7 @@ class SetBeginCommand(QUndoCommand):
def redo(self):
self._lcs.get(self._tab, self._index).begin_kp = float(self._new)
class SetEndCommand(QUndoCommand):
def __init__(self, lcs, tab, index, new_value):
QUndoCommand.__init__(self)
@@ -91,6 +94,7 @@ class SetEdgeCommand(QUndoCommand):
def redo(self):
self._lcs.get(self._tab, self._index).edge = self._new
class SetTypeCommand(QUndoCommand):
def __init__(self, lcs, tab, index, _type):
QUndoCommand.__init__(self)
@@ -109,6 +113,7 @@ class SetTypeCommand(QUndoCommand):
def redo(self):
self._lcs.set(self._tab, self._index, self._new)
class AddCommand(QUndoCommand):
def __init__(self, lcs, tab, index):
QUndoCommand.__init__(self)
@@ -127,6 +132,7 @@ class AddCommand(QUndoCommand):
else:
self._lcs.insert(self._tab, self._index, self._new)
class DelCommand(QUndoCommand):
def __init__(self, lcs, tab, rows):
QUndoCommand.__init__(self)
@@ -147,6 +153,7 @@ class DelCommand(QUndoCommand):
def redo(self):
self._lcs.delete_i(self._tab, self._rows)
class SortCommand(QUndoCommand):
def __init__(self, lcs, tab, _reverse):
QUndoCommand.__init__(self)
+28 -27
View File
@@ -62,6 +62,7 @@ from View.LateralContribution.Edit.Window import EditLateralContributionWindow
logger = logging.getLogger()
class LateralContributionWindow(PamhyrWindow):
_pamhyr_ui = "LateralContributions"
_pamhyr_name = "Lateral contribution"
@@ -70,10 +71,10 @@ class LateralContributionWindow(PamhyrWindow):
name = self._pamhyr_name + " - " + study.name
super(LateralContributionWindow, self).__init__(
title = name,
study = study,
trad = LCTranslate(),
config = config,
title=name,
study=study,
trad=LCTranslate(),
config=config,
parent=parent
)
@@ -88,33 +89,33 @@ class LateralContributionWindow(PamhyrWindow):
for t in ["liquid", "solid", "suspenssion"]:
self._delegate_type = ComboBoxDelegate(
data = self._study.river,
mode = "type",
tab = t,
trad = self._trad,
data=self._study.river,
mode="type",
tab=t,
trad=self._trad,
parent=self
)
self._delegate_edge = ComboBoxDelegate(
data = self._study.river,
mode = "edge",
tab = t,
trad = self._trad,
data=self._study.river,
mode="edge",
tab=t,
trad=self._trad,
parent=self
)
table = self.find(QTableView, f"tableView_{t}")
self._table[t] = TableModel(
table_view = table,
table_headers = self._trad.get_dict("table_headers"),
editable_headers = True,
delegates = {
table_view=table,
table_headers=self._trad.get_dict("table_headers"),
editable_headers=True,
delegates={
"type": self._delegate_type,
"edge": self._delegate_edge,
},
data = self._study.river,
undo = self._undo_stack,
trad = self._trad,
opt_data = t,
data=self._study.river,
undo=self._undo_stack,
trad=self._trad,
opt_data=t,
)
table.setModel(self._table[t])
table.setSelectionBehavior(QAbstractItemView.SelectRows)
@@ -128,9 +129,9 @@ class LateralContributionWindow(PamhyrWindow):
self.plot_layout.addWidget(self.canvas)
self.plot = PlotXY(
canvas = self.canvas,
data = None,
toolbar = None,
canvas=self.canvas,
data=None,
toolbar=None,
)
def setup_connections(self):
@@ -193,9 +194,9 @@ class LateralContributionWindow(PamhyrWindow):
highlight = (lc.begin_kp, lc.end_kp)
self.plot = PlotXY(
canvas = self.canvas,
data = data,
toolbar = None,
canvas=self.canvas,
data=data,
toolbar=None,
)
self.plot.draw(highlight=highlight)
@@ -259,7 +260,7 @@ class LateralContributionWindow(PamhyrWindow):
for row in rows:
win = self.sub_win_filter_first(
"Edit lateral contribution",
contain = [f"({self._lcs.get(tab, row).id})"]
contain=[f"({self._lcs.get(tab, row).id})"]
)
if win is None:
@@ -33,6 +33,7 @@ LC_types = {
"EV": Evaporation,
}
class LCTranslate(PamhyrTranslate):
def __init__(self):
super(LCTranslate, self).__init__()