tiramisu/config.py:
authorEmmanuel Garette <egarette@cadoles.com>
Sun, 22 Sep 2013 19:23:12 +0000 (21:23 +0200)
committerEmmanuel Garette <egarette@cadoles.com>
Sun, 22 Sep 2013 19:23:12 +0000 (21:23 +0200)
 - find byvalue support Multi

tiramisu/value.py:
 - Multi's pop comment

tiramisu/config.py
tiramisu/value.py

index d817fa1..261f6ed 100644 (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,12 +294,13 @@ 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
+                return False
 
         def _filter_by_type():
             if bytype is None:
index 043f15f..d587de1 100644 (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