Compare commits
5 Commits
pkg/dev/ri
...
develop
Author | SHA1 | Date |
---|---|---|
Emmanuel Garette | ce0a46232d | |
Emmanuel Garette | 64017d5cd4 | |
Emmanuel Garette | b0462a1e80 | |
Emmanuel Garette | 8b4af12217 | |
Emmanuel Garette | a5b6352188 |
|
@ -31,6 +31,18 @@ async def test_option_valid_name():
|
|||
with pytest.raises(ValueError):
|
||||
SymLinkOption(1, i)
|
||||
i = SymLinkOption("test1", i)
|
||||
#
|
||||
#
|
||||
#@pytest.mark.asyncio
|
||||
#async def test_option_unvalid_name():
|
||||
# with pytest.raises(ValueError):
|
||||
# IntOption('test.', '')
|
||||
# with pytest.raises(ValueError):
|
||||
# IntOption('test.val', '')
|
||||
# with pytest.raises(ValueError):
|
||||
# IntOption('.test', '')
|
||||
# with pytest.raises(ValueError):
|
||||
# OptionDescription('.test', '', [])
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
@ -484,7 +484,8 @@ class TiramisuOptionInformation(CommonTiramisuOption):
|
|||
|
||||
@option_and_connection
|
||||
async def reset(self,
|
||||
key):
|
||||
key: str,
|
||||
) -> None:
|
||||
"""Remove information"""
|
||||
path = self._option_bag.path
|
||||
values = self._option_bag.config_bag.context.cfgimpl_get_values()
|
||||
|
@ -921,6 +922,16 @@ class TiramisuContextInformation(TiramisuConfig):
|
|||
"""List information's keys"""
|
||||
return await self._config_bag.context.impl_list_information(self._config_bag.connection)
|
||||
|
||||
@connection
|
||||
async def exportation(self):
|
||||
"""Export all informations"""
|
||||
return await self._config_bag.context.cfgimpl_get_values()._p_.exportation_informations(self._config_bag.connection)
|
||||
|
||||
@connection
|
||||
async def importation(self, informations):
|
||||
"""Import informations"""
|
||||
return await self._config_bag.context.cfgimpl_get_values()._p_.importation_informations(self._config_bag.connection, informations)
|
||||
|
||||
|
||||
class TiramisuContextValue(TiramisuConfig):
|
||||
"""Manage config value"""
|
||||
|
|
|
@ -358,10 +358,11 @@ async def manager_callback(callbk: Param,
|
|||
suffix = callbk.suffix
|
||||
else:
|
||||
if not option.impl_is_dynsymlinkoption():
|
||||
msg = 'option "{}" is not dynamic in callback of the option "{}"'
|
||||
raise ConfigError(_(msg).format(callbk_option.impl_get_display_name(),
|
||||
option.impl_get_display_name(),
|
||||
msg = 'option "{}" is not dynamic but is an argument of the dynamic option "{}" in a callback'
|
||||
raise ConfigError(_(msg).format(option.impl_get_display_name(),
|
||||
callbk_option.impl_get_display_name(),
|
||||
))
|
||||
#FIXME in same dynamic option?
|
||||
rootpath = option.rootpath
|
||||
suffix = option.impl_getsuffix()
|
||||
subdyn = callbk_option.getsubdyn()
|
||||
|
|
|
@ -333,14 +333,39 @@ class CalcValue:
|
|||
value = value[index]
|
||||
else:
|
||||
value = None
|
||||
elif None in value and not allow_none:
|
||||
value = []
|
||||
elif remove_duplicate_value:
|
||||
new_value = []
|
||||
for val in value:
|
||||
if val not in new_value:
|
||||
new_value.append(val)
|
||||
value = new_value
|
||||
else:
|
||||
if join is not None:
|
||||
if None not in value:
|
||||
length_val = None
|
||||
for val in value:
|
||||
if isinstance(val, list):
|
||||
if None in val:
|
||||
length_val = None
|
||||
break
|
||||
lval = len(val)
|
||||
if length_val is not None and length_val != lval:
|
||||
raise ValueError(_(f'unexpected value in calc_value with join attribute "{val}" with invalid length "{length_val}"'))
|
||||
length_val = lval
|
||||
new_value = []
|
||||
for idx in range(length_val):
|
||||
idx_val = []
|
||||
for val in value:
|
||||
if isinstance(val, list):
|
||||
idx_val.append(val[idx])
|
||||
else:
|
||||
idx_val.append(val)
|
||||
new_value.append(join.join(idx_val))
|
||||
value = new_value
|
||||
else:
|
||||
value = []
|
||||
elif None in value and not allow_none:
|
||||
value = []
|
||||
elif remove_duplicate_value:
|
||||
new_value = []
|
||||
for val in value:
|
||||
if val not in new_value:
|
||||
new_value.append(val)
|
||||
value = new_value
|
||||
return value
|
||||
|
||||
def value_from_kwargs(self,
|
||||
|
|
|
@ -40,6 +40,8 @@ submulti = 2
|
|||
def valid_name(name):
|
||||
if not isinstance(name, str):
|
||||
return False
|
||||
# if '.' in name:
|
||||
# return False
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -240,7 +240,9 @@ class Values:
|
|||
connection,
|
||||
informations,
|
||||
):
|
||||
await self.del_informations(connection)
|
||||
for path, path_infos in informations.items():
|
||||
path = self._storage.convert_path(path)
|
||||
for key, value in path_infos.items():
|
||||
await connection.execute("INSERT INTO information(key, value, session_id, path) VALUES "
|
||||
"($1, $2, $3, $4)", key, dumps(value), self._storage.database_id, path)
|
||||
|
|
Loading…
Reference in New Issue