1 from abc import ABC, abstractmethod
2 from typing import List
8 def __init__(self, cleanup: bool = False) -> None:
9 """Step initialization.
12 cleanup(bool, optional): Determines if cleanup action should be called.
15 self._steps: List["BaseStep"] = []
16 self._cleanup: bool = cleanup
17 self._parent: "BaseStep" = None
19 def add_step(self, step: "BaseStep") -> None:
22 Add substep and mark step as a substep parent.
25 step (BaseStep): Step object
27 self._steps.append(step)
28 step._parent: "BaseStep" = self
31 def parent(self) -> "BaseStep":
34 If parent is not set the step is a root one.
39 def is_root(self) -> bool:
42 Step is a root if has no parent
45 bool: True if step is a root step, False otherwise
48 return self._parent is None
50 def execute(self) -> None:
53 Run all substeps action before it's own action.
54 Override this method and remember to call `super().action()` before.
57 for step in self._steps:
60 def cleanup(self) -> None:
63 Not all steps has to have cleanup method
67 for step in self._steps:
71 class YamlTemplateBaseStep(BaseStep, ABC):
72 """Base YAML template step."""
76 def yaml_template(self) -> dict:
77 """YAML template abstract property.
79 Every YAML template step need to implement that property.