mirror of https://gitlab.com/pamhyr/pamhyr2
HydraulicStructure: Minor change and fixes.
parent
fb2b1f680f
commit
0a780e5f78
|
|
@ -113,22 +113,13 @@ class HydraulicStructure(SQLSubModel):
|
|||
hs.input_kp = input_kp
|
||||
hs.output_kp = output_kp
|
||||
|
||||
hs.input_reach = None
|
||||
if input_reach_id != -1:
|
||||
hs.input_reach = next(
|
||||
filter(
|
||||
lambda n: n.id == input_reach_id,
|
||||
data["reachs"]
|
||||
)
|
||||
)
|
||||
|
||||
hs.output_reach = None
|
||||
if output_reach_id != -1:
|
||||
hs.output_reach = next(
|
||||
filter(
|
||||
lambda n: n.id == output_reach_id,
|
||||
data["reachs"]
|
||||
)
|
||||
hs.input_reach, hs.output_reach = reduce(
|
||||
lambda acc, n: (
|
||||
n if n.id == input_reach_id else acc[0],
|
||||
n if n.id == output_reach_id else acc[1]
|
||||
),
|
||||
data["reachs"],
|
||||
[None, None]
|
||||
)
|
||||
|
||||
data['hs_id'] = hs_id
|
||||
|
|
@ -143,11 +134,11 @@ class HydraulicStructure(SQLSubModel):
|
|||
|
||||
input_reach_id = -1
|
||||
if self._input_reach is not None:
|
||||
reach_id = self._input_reach.id
|
||||
input_reach_id = self._input_reach.id
|
||||
|
||||
output_reach_id = -1
|
||||
if self._output_reach is not None:
|
||||
reach_id = self._output_reach.id
|
||||
output_reach_id = self._output_reach.id
|
||||
|
||||
sql = (
|
||||
"INSERT INTO " +
|
||||
|
|
@ -232,7 +223,7 @@ class HydraulicStructure(SQLSubModel):
|
|||
return self._data.copy()
|
||||
|
||||
def add(self, index: int):
|
||||
value = BasicHS()
|
||||
value = BasicHS(status=self._status)
|
||||
self._data.insert(index, value)
|
||||
self._status.modified()
|
||||
return value
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ from copy import copy
|
|||
from tools import trace, timer
|
||||
|
||||
from Model.Tools.PamhyrList import PamhyrModelList
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
from Model.HydraulicStructures.HydraulicStructures import HydraulicStructure
|
||||
|
||||
class HydraulicStructureList(PamhyrModelList):
|
||||
|
|
@ -54,7 +52,7 @@ class HydraulicStructureList(PamhyrModelList):
|
|||
return True
|
||||
|
||||
def new(self, lst, index):
|
||||
n = NotDefined(status=self._status)
|
||||
n = HydraulicStructure(status=self._status)
|
||||
self._lst.insert(index, n)
|
||||
self._status.modified()
|
||||
return n
|
||||
|
|
|
|||
Loading…
Reference in New Issue