from collections.abc import Callable
from ppc_robot_lib.steps import AbstractStep
from ppc_robot_lib.tasks import TaskContextInterface
[docs]
class FunctionStep(AbstractStep):
"""
Executes a custom function with full access to the current task context.
"""
def __init__(self, func: Callable[[TaskContextInterface], None]):
"""
:param func: Function or callable to execute, it must accept single argument: ``TaskContext`` instance.
"""
self.func = func
def execute(self, task_ctx: TaskContextInterface) -> None:
self.func(task_ctx)
def get_label_args(self):
if self.func and hasattr(self.func, '__name__'):
return self.func.__name__
else:
return ''