|
@@ -39,8 +39,9 @@ class YAMLLoader:
|
|
|
file_path_to_load = os.path.join(root_dir, yaml_file)
|
|
|
logger.debug("File path to load: %s " % file_path_to_load)
|
|
|
if os.path.isfile(yaml_file):
|
|
|
- data = IncludeLoader(open(file_path_to_load, 'r')).get_data()
|
|
|
+ # data = IncludeLoader(open(file_path_to_load, 'r')).get_data()
|
|
|
# print Utils.print_yaml_nicely(data)
|
|
|
+ data = IncludeImport(file_path_to_load).get_data()
|
|
|
return data
|
|
|
else:
|
|
|
raise YAMLFileNotFound("File %s not found" % file_path_to_load)
|
|
@@ -50,7 +51,7 @@ class IncludeLoader(yaml.Loader):
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
super(IncludeLoader, self).__init__(*args, **kwargs)
|
|
|
- self.add_constructor('!include', self._include)
|
|
|
+ self.add_constructor('#include', self._include)
|
|
|
if 'root' in kwargs:
|
|
|
self.root = kwargs['root']
|
|
|
elif isinstance(self.stream, file):
|
|
@@ -64,4 +65,30 @@ class IncludeLoader(yaml.Loader):
|
|
|
self.root = os.path.dirname(filename)
|
|
|
data = yaml.load(open(filename, 'r'))
|
|
|
self.root = oldRoot
|
|
|
- return data
|
|
|
+ return data
|
|
|
+
|
|
|
+
|
|
|
+class IncludeImport(object):
|
|
|
+
|
|
|
+ def __init__(self, file_path):
|
|
|
+
|
|
|
+ self.data = yaml.load(open(file_path, 'r'))
|
|
|
+
|
|
|
+ print "content: %s" % self.data
|
|
|
+ if isinstance(self.data, list):
|
|
|
+ for el in self.data:
|
|
|
+ if "includes" in el:
|
|
|
+ for inc in el["includes"]:
|
|
|
+ self.update(yaml.load(open(inc)))
|
|
|
+
|
|
|
+ def get_data(self):
|
|
|
+ return self.data
|
|
|
+
|
|
|
+ def update(self, data_to_add):
|
|
|
+ # print "cur_data: %s" % self.data
|
|
|
+ # print "data to add %s" % data_to_add
|
|
|
+ # we add each synapse inside the extended brain into the main brain data
|
|
|
+ for el in data_to_add:
|
|
|
+ self.data.append(el)
|
|
|
+ # print "final data: %s" % self.data
|
|
|
+
|