tiramisu/config.py:
- find byvalue support Multi tiramisu/value.py: - Multi's pop comment
This commit is contained in:
parent
c84d13a1c6
commit
051f1c8774
|
@ -26,7 +26,7 @@ from tiramisu.option import OptionDescription, Option, SymLinkOption
|
||||||
from tiramisu.setting import groups, Settings, default_encoding
|
from tiramisu.setting import groups, Settings, default_encoding
|
||||||
from tiramisu.storage import get_storages, get_storage, set_storage, \
|
from tiramisu.storage import get_storages, get_storage, set_storage, \
|
||||||
_impl_getstate_setting
|
_impl_getstate_setting
|
||||||
from tiramisu.value import Values
|
from tiramisu.value import Values, Multi
|
||||||
from tiramisu.i18n import _
|
from tiramisu.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,12 +294,13 @@ class SubConfig(object):
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
value = getattr(self, path)
|
value = getattr(self, path)
|
||||||
if value == byvalue:
|
if isinstance(value, Multi):
|
||||||
return True
|
return byvalue in value
|
||||||
|
else:
|
||||||
|
return value == byvalue
|
||||||
except PropertiesOptionError: # a property is a restriction
|
except PropertiesOptionError: # a property is a restriction
|
||||||
# upon the access of the value
|
# upon the access of the value
|
||||||
pass
|
return False
|
||||||
return False
|
|
||||||
|
|
||||||
def _filter_by_type():
|
def _filter_by_type():
|
||||||
if bytype is None:
|
if bytype is None:
|
||||||
|
|
|
@ -544,12 +544,15 @@ class Multi(list):
|
||||||
"").format(str(value),
|
"").format(str(value),
|
||||||
self.opt._name, err))
|
self.opt._name, err))
|
||||||
|
|
||||||
def pop(self, key, force=False):
|
def pop(self, index, force=False):
|
||||||
"""the list value can be updated (poped)
|
"""the list value can be updated (poped)
|
||||||
only if the option is a master
|
only if the option is a master
|
||||||
|
|
||||||
:param key: index of the element to pop
|
:param index: remove item a index
|
||||||
:return: the requested element
|
:type index: int
|
||||||
|
:param force: force pop item (withoud check master/slave)
|
||||||
|
:type force: boolean
|
||||||
|
:returns: item at index
|
||||||
"""
|
"""
|
||||||
if not force:
|
if not force:
|
||||||
if self.opt.impl_get_multitype() == multitypes.slave:
|
if self.opt.impl_get_multitype() == multitypes.slave:
|
||||||
|
@ -562,8 +565,8 @@ class Multi(list):
|
||||||
#get multi without valid properties
|
#get multi without valid properties
|
||||||
values.getitem(slave,
|
values.getitem(slave,
|
||||||
validate_properties=False
|
validate_properties=False
|
||||||
).pop(key, force=True)
|
).pop(index, force=True)
|
||||||
#set value without valid properties
|
#set value without valid properties
|
||||||
ret = super(Multi, self).pop(key)
|
ret = super(Multi, self).pop(index)
|
||||||
self.context().cfgimpl_get_values()._setvalue(self.opt, self.path, self, validate_properties=not force)
|
self.context().cfgimpl_get_values()._setvalue(self.opt, self.path, self, validate_properties=not force)
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue