IC: Fix sql_save as generator value type.

setup.py
Pierre-Antoine Rouby 2023-11-20 16:10:10 +01:00
parent fd0a8ddf51
commit ccbbc83502
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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)