Source code for doitoml.actors._actor
"""Base actor for ``doitoml``."""
import abc
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional
from doitoml.types import ExecutionContext
if TYPE_CHECKING:
from doitoml.doitoml import DoiTOML
from doitoml.sources._config import ConfigSource
CallableAction = Callable[[], Optional[bool]]
[docs]
class Actor:
"""A base class for a ``doitoml`` actor plugin."""
#: a reference to the parent
doitoml: "DoiTOML"
#: the rank of the action
rank = 100
def __init__(self, doitoml: "DoiTOML") -> None:
"""Create an Actor and remember its parent."""
self.doitoml = doitoml
[docs]
@abc.abstractmethod
def knows(self, action: Dict[str, Any]) -> bool:
"""Whether the actor knows how to transform and perform an action."""
[docs]
@staticmethod
def schema() -> Optional[Dict[str, Any]]: # pragma: no cover
"""Provide the ``doitoml`` schema to reflect this action's structure.
In a future version, this will become required.
"""
return None