electrolyt.plan¶
Classes¶
Error when parsing or executing the plan. |
|
Electrolyt Plan. |
|
Store the action environment. |
|
Context in which a Plan is executed. |
Module Contents¶
- class electrolyt.plan.PlanError¶
Bases:
e3.error.E3ErrorError when parsing or executing the plan.
- class electrolyt.plan.Plan(data: dict[str, Any], entry_point_cls: dict[str, collections.abc.Callable[Ellipsis, e3.electrolyt.entry_point.EntryPoint]] | None = None, plan_ext: str = '.plan')¶
Electrolyt Plan.
- Variables:
entry_points (dict) – list of entry points found in the plans
- mod¶
- entry_points: dict[str, e3.electrolyt.entry_point.EntryPoint]¶
- plan_ext = '.plan'¶
- plan_date¶
- toggleable_bool_group¶
- cond(name: str, date: collections.abc.Callable[[datetime.datetime], bool]) e3.collection.toggleable_bool.ToggleableBoolean¶
Generate a new conditional boolean.
- Parameters:
name – variable name
date – function that takes the plan date and return a boolean. This can be used to set a value depending on the day of the week, e.g. by setting the constant to True on weekend: lambda d: d.isoweekday() in [6, 7]
- load(filename: str) None¶
Load python code from file.
- Parameters:
filename – path to the python code
- check(code_ast: ast.AST) None¶
Check plan coding style.
- load_chunk(source_code: bytes, filename: str = '<unknown>') None¶
Load a chunk of Python code.
- Parameters:
source_code – python source code
filename – filename associated with the Python code
- class electrolyt.plan.PlanActionEnv¶
Bases:
e3.env.BaseEnvStore the action environment.
This includes the build/host/target as well as additional parameters coming from the plan.
- action: str¶
- plan_line: str¶
- plan_args: dict[str, Any]¶
- plan_call_args: dict[str, Any]¶
- push_to_store: bool¶
- default_build: bool¶
- module: str | None¶
- source_packages: list[str] | None¶
- qualifier: str | dict[str, str | bool | Iterable[str]] | None¶
- class electrolyt.plan.PlanContext(stack: list[PlanActionEnv] | None = None, plan: Plan | None = None, ignore_disabled: bool = True, server: e3.env.BaseEnv | None = None, build: str | None = None, host: str | None = None, target: str | None = None, enabled: bool = True, default_push_to_store: bool = False, **kwargs: Any)¶
Context in which a Plan is executed.
- ignore_disabled = True¶
- actions: dict[str, collections.abc.Callable]¶
- action_list: list[PlanActionEnv] = []¶
- register_action(name: str, fun: collections.abc.Callable) None¶
Register a function that correspond to an action.
- Parameters:
name – name used in the plans
fun – python function. The function itself does not require an implementation. Only signature is is used
- property env: PlanActionEnv¶
Get environment for current scope.
- Returns:
the current scope environment
- property default_env: e3.env.BaseEnv¶
Get initial environment.
- Returns:
the environment set during creation of the initial context
- execute(plan: Plan, entry_point_name: str, verify: bool = False, entry_point_parameters: dict | None = None) list[PlanActionEnv]¶
Execute a plan.
- Parameters:
plan – the plan to execute
entry_point_name – entry point to call in the plan. It can be either a function name in the plan or an entry_point function
verify – verify whether the entry point name is a electrolyt entry point
entry_point_parameters – parameters passed as keyword arguments to the entry point
- Raise:
PlanError
- Returns:
a list of plan actions
- _add_action(name: str, *args: Any, **kwargs: Any) None¶
Process action calls in plans.
- Parameters:
name – action name
args – positional arguments of the action call
kwargs – keyword arguments of the action call
- __enter__() None¶
- __exit__(_type: type[BaseException] | None, _value: BaseException | None, _tb: types.TracebackType | None) None¶