mirror of https://gitlab.com/pamhyr/pamhyr2
pamhyr: Fix pep8.
parent
328f5656bf
commit
5525fff1fe
|
|
@ -75,6 +75,7 @@ class Friction(SQLSubModel):
|
||||||
cls._db_update_to_0_1_0(execute, data)
|
cls._db_update_to_0_1_0(execute, data)
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "friction"
|
table = "friction"
|
||||||
|
|
@ -125,7 +126,8 @@ class Friction(SQLSubModel):
|
||||||
if int(begin_strickler_pid) != -1:
|
if int(begin_strickler_pid) != -1:
|
||||||
begin_strickler = next(
|
begin_strickler = next(
|
||||||
filter(
|
filter(
|
||||||
lambda s: s.pamhyr_id == begin_strickler_pid, stricklers
|
lambda s: s.pamhyr_id == begin_strickler_pid,
|
||||||
|
stricklers
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class Data(SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute, ext=""):
|
def _db_create(cls, execute, ext=""):
|
||||||
execute(f"""
|
execute(f"""
|
||||||
CREATE TABLE initial_conditions(
|
CREATE TABLE initial_conditions{ext} (
|
||||||
{cls.create_db_add_pamhyr_id()},
|
{cls.create_db_add_pamhyr_id()},
|
||||||
ind INTEGER NOT NULL,
|
ind INTEGER NOT NULL,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,8 @@ class LateralContribution(SQLSubModel):
|
||||||
tab = data["tab"]
|
tab = data["tab"]
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, name, type, reach, begin_section, end_section " +
|
"SELECT pamhyr_id, name, type, " +
|
||||||
|
"reach, begin_section, end_section " +
|
||||||
f"FROM lateral_contribution WHERE tab = '{tab}'"
|
f"FROM lateral_contribution WHERE tab = '{tab}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -268,7 +269,12 @@ class LateralContribution(SQLSubModel):
|
||||||
lc._end_section = None
|
lc._end_section = None
|
||||||
|
|
||||||
if row[3] != -1:
|
if row[3] != -1:
|
||||||
lc.reach = next(filter(lambda e: e.id == row[3], data["edges"]))
|
lc.reach = next(
|
||||||
|
filter(
|
||||||
|
lambda e: e.id == row[3],
|
||||||
|
data["edges"]
|
||||||
|
)
|
||||||
|
)
|
||||||
lc._begin_section = lc.reach.profile(row[4])
|
lc._begin_section = lc.reach.profile(row[4])
|
||||||
lc._end_section = lc.reach.profile(row[5])
|
lc._end_section = lc.reach.profile(row[5])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ from Model.Scenario import Scenario
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class Data(SQLSubModel):
|
class Data(SQLSubModel):
|
||||||
_sub_classes = []
|
_sub_classes = []
|
||||||
|
|
||||||
|
|
@ -121,12 +122,11 @@ class Data(SQLSubModel):
|
||||||
"reservoir_data " +
|
"reservoir_data " +
|
||||||
"(pamhyr_id, ind, elevation, surface, reservoir) " +
|
"(pamhyr_id, ind, elevation, surface, reservoir) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{pid}, {ind}, '{elevation}', {surface}, "+
|
f"{pid}, {ind}, '{elevation}', {surface}, " +
|
||||||
f"{reservoir._pamhyr_id}" +
|
f"{reservoir._pamhyr_id}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return self._data[key]
|
return self._data[key]
|
||||||
|
|
||||||
|
|
@ -175,7 +175,6 @@ class Reservoir(SQLSubModel):
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update_to_0_1_0(cls, execute, data):
|
def _db_update_to_0_1_0(cls, execute, data):
|
||||||
table = "reservoir"
|
table = "reservoir"
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,8 @@ class RiverNode(Node, SQLSubModel):
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute(
|
execute(
|
||||||
"INSERT OR REPLACE INTO river_node(pamhyr_id, name, x, y) VALUES (" +
|
"INSERT OR REPLACE INTO river_node(pamhyr_id, name, x, y) " +
|
||||||
|
"VALUES (" +
|
||||||
f"{self._pamhyr_id}, " +
|
f"{self._pamhyr_id}, " +
|
||||||
f"'{self._db_format(self.name)}', " +
|
f"'{self._db_format(self.name)}', " +
|
||||||
f"{self.x}, {self.y}" +
|
f"{self.x}, {self.y}" +
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ class Scenario(SQLSubModel):
|
||||||
if self.parent is not None:
|
if self.parent is not None:
|
||||||
parent = self.parent._id
|
parent = self.parent._id
|
||||||
|
|
||||||
sql = (
|
execute(
|
||||||
"INSERT OR REPLACE INTO " +
|
"INSERT OR REPLACE INTO " +
|
||||||
"scenario(id, name, description, revision, parent_id) " +
|
"scenario(id, name, description, revision, parent_id) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
|
|
@ -156,7 +156,6 @@ class Scenario(SQLSubModel):
|
||||||
f"{parent}" +
|
f"{parent}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
execute(sql)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ class SedimentLayer(SQLSubModel):
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
if self._name == "":
|
if self._name == "":
|
||||||
return f"SL{self.id + 1}"
|
return f"SL #{self.pamhyr_id}"
|
||||||
|
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue