tiramisu/config.py:

- find byvalue support Multi

tiramisu/value.py:
 - Multi's pop comment
This commit is contained in:
Emmanuel Garette 2013-09-22 21:23:12 +02:00
parent c84d13a1c6
commit 051f1c8774
2 changed files with 14 additions and 10 deletions

View File

@ -26,7 +26,7 @@ from tiramisu.option import OptionDescription, Option, SymLinkOption
from tiramisu.setting import groups, Settings, default_encoding
from tiramisu.storage import get_storages, get_storage, set_storage, \
_impl_getstate_setting
from tiramisu.value import Values
from tiramisu.value import Values, Multi
from tiramisu.i18n import _
@ -294,11 +294,12 @@ class SubConfig(object):
return True
try:
value = getattr(self, path)
if value == byvalue:
return True
if isinstance(value, Multi):
return byvalue in value
else:
return value == byvalue
except PropertiesOptionError: # a property is a restriction
# upon the access of the value
pass
return False
def _filter_by_type():

View File

@ -544,12 +544,15 @@ class Multi(list):
"").format(str(value),
self.opt._name, err))
def pop(self, key, force=False):
def pop(self, index, force=False):
"""the list value can be updated (poped)
only if the option is a master
:param key: index of the element to pop
:return: the requested element
:param index: remove item a index
:type index: int
:param force: force pop item (withoud check master/slave)
:type force: boolean
:returns: item at index
"""
if not force:
if self.opt.impl_get_multitype() == multitypes.slave:
@ -562,8 +565,8 @@ class Multi(list):
#get multi without valid properties
values.getitem(slave,
validate_properties=False
).pop(key, force=True)
).pop(index, force=True)
#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)
return ret