mirror of https://gitlab.com/pamhyr/pamhyr2
IC: Fix sql_save as generator value type.
parent
fd0a8ddf51
commit
ccbbc83502
|
|
@ -17,12 +17,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import types
|
||||
import logging
|
||||
|
||||
from copy import copy
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.Tools.PamhyrDict import PamhyrModelDict
|
||||
from Model.InitialConditions.InitialConditions import InitialConditions
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class InitialConditionsDict(PamhyrModelDict):
|
||||
_sub_classes = [
|
||||
|
|
@ -55,6 +59,10 @@ class InitialConditionsDict(PamhyrModelDict):
|
|||
|
||||
for reach in self._dict:
|
||||
data["reach"] = reach
|
||||
v = self._dict[reach]
|
||||
if isinstance(v, types.GeneratorType):
|
||||
self._dict[reach] = list(v)[0]
|
||||
|
||||
ok &= self._dict[reach]._db_save(execute, data)
|
||||
|
||||
return ok
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import types
|
||||
import logging
|
||||
|
||||
from copy import copy
|
||||
|
|
@ -64,7 +65,12 @@ class PamhyrModelDict(SQLSubModel):
|
|||
|
||||
def get(self, key):
|
||||
if key in self._dict:
|
||||
return self._dict[key]
|
||||
v = self._dict[key]
|
||||
|
||||
if type(v) == types.GeneratorType:
|
||||
return list(v)
|
||||
|
||||
return v
|
||||
|
||||
new = self.new(key)
|
||||
self.set(key, new)
|
||||
|
|
|
|||
Loading…
Reference in New Issue