Add support for the all: statement
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Mon, 23 Apr 2018 13:04:42 +0000 (15:04 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Mon, 23 Apr 2018 13:04:42 +0000 (15:04 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
test.py

diff --git a/test.py b/test.py
index 271e809..c755cbc 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -414,6 +414,12 @@ class recipe():
         self.path = os.path.dirname(self.recipe_file)
         self.log.debug("Path of recipe is: {}".format(self.recipe_file))
         self._recipe = None
+        self._machines = None
+
+        self.in_recursion = True
+        if len(circle) == 0:
+            self.in_recursion = False
+
         self.circle = circle
         self.log.debug(circle)
         self.log.debug(self.circle)
@@ -434,6 +440,16 @@ class recipe():
 
         return self._recipe
 
+    @property
+    def machines(self):
+        if not self._machines:
+            self._machines = []
+            for line in self._recipe:
+                if line[0] != "all" and line[0] not in self._machines:
+                    self._machines.append(line[0])
+
+        return self._machines
+
     def parse(self):
         self._recipe = []
         i = 1
@@ -476,6 +492,18 @@ class recipe():
                 self._recipe.append((machine.strip(), extra.strip(), cmd.strip()))
             i = i + 1
 
+            if not self.in_recursion:
+                tmp_recipe = []
+                for line in self._recipe:
+                    if line[0] != "all":
+                        tmp_recipe.append(line)
+                    else:
+                        for machine in self.machines:
+                            tmp_recipe.append((machine.strip(), line[1], line[2]))
+
+                self._recipe = tmp_recipe
+
+
 
 class test():
     def __init__(self, path):