def __init__( self, conditions=(), actions=(), next=StepNext.CONTINUE, cond_op=StepConditionOperator.ALL, enabled=True ): self._conditions = conditions self._actions = actions self._next = StepNext(next) self._enabled = bool(enabled) self._cond_op = StepConditionOperator(cond_op)
def unserialize(cls, step_data): kwargs = { "conditions": [Condition.unserialize(cond) for cond in step_data.get("conditions", ())], "actions": [Action.unserialize(action) for action in step_data.get("actions", ())], } if "next" in step_data: kwargs["next"] = StepNext(step_data["next"]) if "cond_op" in step_data: kwargs["cond_op"] = StepConditionOperator(step_data["cond_op"]) if "enabled" in step_data: kwargs["enabled"] = bool(step_data["enabled"]) return cls(**kwargs)