浏览代码

add check synapses

Nicolas Marcq 8 年之前
父节点
当前提交
3f83eb4f83
共有 2 个文件被更改,包括 15 次插入12 次删除
  1. 4 12
      core/ConfigurationManager/BrainLoader.py
  2. 11 0
      core/ConfigurationManager/ConfigurationChecker.py

+ 4 - 12
core/ConfigurationManager/BrainLoader.py

@@ -22,17 +22,6 @@ class BrainLoader(YAMLLoader):
     def get_config(self):
         return YAMLLoader.get_config(self)
 
-    def get_events(self):
-        events_in_brain = list()
-        for el in self.get_config():
-            whens = el["when"]
-            for when in whens:
-                # if key event exist in when of the task
-                if 'event' in when:
-                    events_in_brain.append(when['event'])
-
-        return events_in_brain
-
     def get_brain(self):
         """
         return a brain object from YAML settings
@@ -55,7 +44,10 @@ class BrainLoader(YAMLLoader):
                 new_synapse = Synapse(name=name, neurons=neurons, signals=signals)
                 synapses.append(new_synapse)
         brain.synapes = synapses
-        return brain
+        # check that no synapse have the same name than another
+        if ConfigurationChecker().check_synapes(synapses):
+            return brain
+        return None
 
     def _get_neurons(self, neurons_dict):
         """

+ 11 - 0
core/ConfigurationManager/ConfigurationChecker.py

@@ -66,3 +66,14 @@ class ConfigurationChecker:
         if order_dict is not None:
             return True
         return False
+
+    @staticmethod
+    def check_synapes(synapses_list):
+        """
+        Check the synapse list is ok. No double same name
+        :param synapses_list:
+        :type synapses_list: list of Synapse
+        :return:
+        """
+        # TODO: check no same name
+        pass