Merge branch 'master' of ssh://git.labs.libre-entreprise.org/gitroot/tiramisu
[tiramisu.git] / tiramisu / option.py
index d483d9e..6e4d9da 100644 (file)
@@ -168,21 +168,35 @@ class BaseOption(object):
                 consistencies = self._state_consistencies
             else:
                 consistencies = self._consistencies
-            new_value = []
-            for consistency in consistencies:
-                if load:
-                    new_value.append((consistency[0],
-                                      descr.impl_get_opt_by_path(
-                                          consistency[1])))
-                else:
-                    new_value.append((consistency[0],
-                                      descr.impl_get_path_by_opt(
-                                          consistency[1])))
+            if isinstance(consistencies, list):
+                new_value = []
+                for consistency in consistencies:
+                    if load:
+                        new_value.append((consistency[0],
+                                          descr.impl_get_opt_by_path(
+                                              consistency[1])))
+                    else:
+                        new_value.append((consistency[0],
+                                          descr.impl_get_path_by_opt(
+                                              consistency[1])))
+
+            else:
+                new_value = {}
+                for key, _consistencies in consistencies.items():
+                    new_value[key] = []
+                    for key_cons, _cons in _consistencies:
+                        _list_cons = []
+                        for _con in _cons:
+                            if load:
+                                _list_cons.append(descr.impl_get_opt_by_path(_con))
+                            else:
+                                _list_cons.append(descr.impl_get_path_by_opt(_con))
+                        new_value[key].append((key_cons, tuple(_list_cons)))
             if load:
                 del(self._state_consistencies)
-                self._consistencies = tuple(new_value)
+                self._consistencies = new_value
             else:
-                self._state_consistencies = tuple(new_value)
+                self._state_consistencies = new_value
 
     def _impl_convert_requires(self, descr, load=False):
         """export of the requires during the serialization process
@@ -644,8 +658,10 @@ else:
 
 
 class SymLinkOption(BaseOption):
-    __slots__ = ('_name', '_opt', '_state_opt')
+    __slots__ = ('_name', '_opt', '_state_opt', '_consistencies')
     _opt_type = 'symlink'
+    #not return _opt consistencies
+    _consistencies = {}
 
     def __init__(self, name, opt):
         self._name = name
@@ -671,6 +687,12 @@ class SymLinkOption(BaseOption):
         del(self._state_opt)
         super(SymLinkOption, self)._impl_setstate(descr)
 
+    def _impl_convert_consistencies(self, descr, load=False):
+        if load:
+            del(self._state_consistencies)
+        else:
+            self._state_consistencies = None
+
 
 class IPOption(Option):
     "represents the choice of an ip"