pynenc.trigger.trigger_context

Context for trigger evaluation in Pynenc.

This module defines the TriggerContext class which collects valid conditions and provides access to their contexts for trigger evaluation.

Module Contents

Classes

TriggerContext

Context for trigger evaluation.

Data

C

API

pynenc.trigger.trigger_context.C

‘TypeVar(…)’

class pynenc.trigger.trigger_context.TriggerContext(timestamp: datetime.datetime | None = None, valid_conditions: dict[str, pynenc.trigger.conditions.ValidCondition] | None = None)[source]

Context for trigger evaluation.

Contains a collection of valid conditions (satisfied conditions with their contexts), which are used to evaluate whether a trigger definition should execute.

Initialization

Initialize the trigger context.

Parameters:
  • timestamp – Time of context creation, defaults to current time

  • valid_conditions – Dictionary of initial valid conditions, if any

static build_conditions_dict(valid_conditions: dict[str, pynenc.trigger.conditions.ValidCondition]) dict[str, pynenc.trigger.conditions.TriggerCondition][source]

Build a mapping from condition IDs to condition objects.

Parameters:

valid_conditions – Dictionary of valid conditions

Returns:

Dictionary mapping condition IDs to their condition objects

add_valid_condition(valid_condition: pynenc.trigger.conditions.ValidCondition) None[source]

Add a valid condition to this context.

Parameters:

valid_condition – The valid condition to add

has_condition(condition_id: str) bool[source]

Check if a specific condition is valid in this context.

Parameters:

condition_id – ID of the condition to check

Returns:

True if the condition is valid