mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
pep8: Some modifications to respect pep8 standard code.
This commit is contained in:
1 parent
8544dd1144
commit
fa2454d079
152 files changed
+1626
-1277
No files matched your search
@@ -25,12 +25,13 @@ from Model.Except import NotImplementedMethodeError
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class BoundaryCondition(SQLSubModel):
|
||||
_sub_classes = []
|
||||
_id_cnt = 0
|
||||
|
||||
def __init__(self, id:int = -1, name:str = "",
|
||||
status = None):
|
||||
def __init__(self, id: int = -1, name: str = "",
|
||||
status=None):
|
||||
super(BoundaryCondition, self).__init__()
|
||||
|
||||
self._status = status
|
||||
@@ -101,7 +102,7 @@ class BoundaryCondition(SQLSubModel):
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def _sql_load(cls, execute, data = None):
|
||||
def _sql_load(cls, execute, data=None):
|
||||
new = []
|
||||
tab = data["tab"]
|
||||
|
||||
@@ -115,9 +116,9 @@ class BoundaryCondition(SQLSubModel):
|
||||
t = row[2]
|
||||
ctor = cls._get_ctor_from_type(t)
|
||||
bc = ctor(
|
||||
id = row[0],
|
||||
name = row[1],
|
||||
status = data['status']
|
||||
id=row[0],
|
||||
name=row[1],
|
||||
status=data['status']
|
||||
)
|
||||
|
||||
bc.node = None
|
||||
@@ -143,7 +144,7 @@ class BoundaryCondition(SQLSubModel):
|
||||
|
||||
return new
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
def _sql_save(self, execute, data=None):
|
||||
tab = data["tab"]
|
||||
|
||||
execute(f"DELETE FROM boundary_condition WHERE id = {self.id}")
|
||||
@@ -155,7 +156,7 @@ class BoundaryCondition(SQLSubModel):
|
||||
|
||||
sql = (
|
||||
"INSERT INTO " +
|
||||
"boundary_condition(id, name, type, tab, node) "+
|
||||
"boundary_condition(id, name, type, tab, node) " +
|
||||
"VALUES (" +
|
||||
f"{self.id}, '{self._sql_format(self._name)}', " +
|
||||
f"'{self._sql_format(self._type)}', '{tab}', {node}" +
|
||||
@@ -170,7 +171,7 @@ class BoundaryCondition(SQLSubModel):
|
||||
|
||||
sql = (
|
||||
"INSERT INTO " +
|
||||
"boundary_condition_data(ind, data0, data1, bc) "+
|
||||
"boundary_condition_data(ind, data0, data1, bc) " +
|
||||
f"VALUES ({ind}, '{data0}', {data1}, {self.id})"
|
||||
)
|
||||
execute(sql)
|
||||
@@ -246,7 +247,7 @@ class BoundaryCondition(SQLSubModel):
|
||||
new_1 = self._default_1
|
||||
|
||||
if len(header) != 0:
|
||||
for i in [0,1]:
|
||||
for i in [0, 1]:
|
||||
for j in range(len(header)):
|
||||
if self._header[i] == header[j]:
|
||||
if i == 0:
|
||||
@@ -259,13 +260,13 @@ class BoundaryCondition(SQLSubModel):
|
||||
|
||||
return (new_0, new_1)
|
||||
|
||||
def add(self, index:int):
|
||||
def add(self, index: int):
|
||||
value = (self._default_0, self._default_1)
|
||||
self._data.insert(index, value)
|
||||
self._status.modified()
|
||||
return value
|
||||
|
||||
def insert(self, index:int, value):
|
||||
def insert(self, index: int, value):
|
||||
self._data.insert(index, value)
|
||||
self._status.modified()
|
||||
|
||||
@@ -306,29 +307,28 @@ class BoundaryCondition(SQLSubModel):
|
||||
l.append(r)
|
||||
return l
|
||||
|
||||
|
||||
def _set_i_c_v(self, index, column, value):
|
||||
v = list(self._data[index])
|
||||
v[column] = self._types[column](value)
|
||||
self._data[index] = tuple(v)
|
||||
self._status.modified()
|
||||
|
||||
def set_i_0(self, index:int, value):
|
||||
def set_i_0(self, index: int, value):
|
||||
self._set_i_c_v(index, 0, value)
|
||||
|
||||
def set_i_1(self, index:int, value):
|
||||
def set_i_1(self, index: int, value):
|
||||
self._set_i_c_v(index, 1, value)
|
||||
|
||||
@timer
|
||||
def convert(self, cls):
|
||||
new = cls(name = self.name, status = self._status)
|
||||
new = cls(name=self.name, status=self._status)
|
||||
new.node = self.node
|
||||
|
||||
for i, _ in enumerate(self.data):
|
||||
new.add(i)
|
||||
|
||||
for i in [0,1]:
|
||||
for j in [0,1]:
|
||||
for i in [0, 1]:
|
||||
for j in [0, 1]:
|
||||
if self._header[i] == new.header[j]:
|
||||
for ind, v in self.data:
|
||||
try:
|
||||
|
||||
@@ -30,6 +30,7 @@ from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||
Solid,
|
||||
)
|
||||
|
||||
|
||||
class BoundaryConditionList(PamhyrModelListWithTab):
|
||||
_tabs_list = ["liquid", "solid", "suspenssion"]
|
||||
_sub_classes = [
|
||||
@@ -37,8 +38,8 @@ class BoundaryConditionList(PamhyrModelListWithTab):
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def _sql_load(cls, execute, data = None):
|
||||
new = cls(status = data['status'])
|
||||
def _sql_load(cls, execute, data=None):
|
||||
new = cls(status=data['status'])
|
||||
|
||||
if data is None:
|
||||
data = {}
|
||||
@@ -51,7 +52,7 @@ class BoundaryConditionList(PamhyrModelListWithTab):
|
||||
|
||||
return new
|
||||
|
||||
def _sql_save(self, execute, data = None):
|
||||
def _sql_save(self, execute, data=None):
|
||||
execute("DELETE FROM boundary_condition")
|
||||
|
||||
if data is None:
|
||||
@@ -60,7 +61,7 @@ class BoundaryConditionList(PamhyrModelListWithTab):
|
||||
for tab in self._tabs:
|
||||
data["tab"] = tab
|
||||
for bc in self._tabs[tab]:
|
||||
bc._sql_save(execute, data = data)
|
||||
bc._sql_save(execute, data=data)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||
|
||||
|
||||
class NotDefined(BoundaryCondition):
|
||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||
def __init__(self, id: int = -1, name: str = "", status=None):
|
||||
super(NotDefined, self).__init__(id=id, name=name, status=status)
|
||||
|
||||
self._type = "ND"
|
||||
@@ -32,9 +32,11 @@ class NotDefined(BoundaryCondition):
|
||||
def _default_0(self):
|
||||
return 0.0
|
||||
|
||||
|
||||
class PonctualContribution(BoundaryCondition):
|
||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||
super(PonctualContribution, self).__init__(id=id, name=name, status=status)
|
||||
def __init__(self, id: int = -1, name: str = "", status=None):
|
||||
super(PonctualContribution, self).__init__(
|
||||
id=id, name=name, status=status)
|
||||
|
||||
self._type = "PC"
|
||||
self._header = ["time", "discharge"]
|
||||
@@ -44,8 +46,9 @@ class PonctualContribution(BoundaryCondition):
|
||||
def compatibility(cls):
|
||||
return ["liquid"]
|
||||
|
||||
|
||||
class TimeOverZ(BoundaryCondition):
|
||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||
def __init__(self, id: int = -1, name: str = "", status=None):
|
||||
super(TimeOverZ, self).__init__(id=id, name=name, status=status)
|
||||
|
||||
self._type = "TZ"
|
||||
@@ -56,9 +59,11 @@ class TimeOverZ(BoundaryCondition):
|
||||
def compatibility(cls):
|
||||
return ["liquid"]
|
||||
|
||||
|
||||
class TimeOverDischarge(BoundaryCondition):
|
||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||
super(TimeOverDischarge, self).__init__(id=id, name=name, status=status)
|
||||
def __init__(self, id: int = -1, name: str = "", status=None):
|
||||
super(TimeOverDischarge, self).__init__(
|
||||
id=id, name=name, status=status)
|
||||
|
||||
self._type = "TD"
|
||||
self._header = ["time", "discharge"]
|
||||
@@ -68,8 +73,9 @@ class TimeOverDischarge(BoundaryCondition):
|
||||
def compatibility(cls):
|
||||
return ["liquid"]
|
||||
|
||||
|
||||
class ZOverDischarge(BoundaryCondition):
|
||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||
def __init__(self, id: int = -1, name: str = "", status=None):
|
||||
super(ZOverDischarge, self).__init__(id=id, name=name, status=status)
|
||||
|
||||
self._type = "ZD"
|
||||
@@ -86,7 +92,7 @@ class ZOverDischarge(BoundaryCondition):
|
||||
|
||||
|
||||
class Solid(BoundaryCondition):
|
||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||
def __init__(self, id: int = -1, name: str = "", status=None):
|
||||
super(Solid, self).__init__(id=id, name=name, status=status)
|
||||
|
||||
self.d50 = 0.002
|
||||
|
||||
Reference in new issue
Block a user