pynenc.trigger.conditions.event

Context for event-based conditions.

This module defines the EventContext class, which provides the necessary data for evaluating event-based trigger conditions. It includes the event ID and the associated payload.

Module Contents

Classes

EventContext

Context for event-based conditions.

EventCondition

Condition based on system events.

API

class pynenc.trigger.conditions.event.EventContext[source]

Bases: pynenc.trigger.conditions.base.ConditionContext

Context for event-based conditions.

Contains the necessary information about an event that occurred in the system, allowing event-based conditions to determine if they should trigger.

event_id: str

None

event_code: str

None

payload: dict[str, Any]

‘field(…)’

property context_id: str
_to_json(app: pynenc.app.Pynenc) dict[str, Any][source]

Create a serializable representation of this event context.

Parameters:

app – Pynenc application instance

Returns:

Dictionary with serialized context data

classmethod _from_json(data: dict[str, Any], app: pynenc.app.Pynenc) pynenc.trigger.conditions.event.EventContext[source]

Create an EventContext from parsed JSON data.

Parameters:
  • data – Dictionary with context data

  • app – Pynenc application instance

Returns:

A new EventContext instance

class pynenc.trigger.conditions.event.EventCondition(event_code: str, payload_filter: pynenc.trigger.arguments.ArgumentFilter)[source]

Bases: pynenc.trigger.conditions.base.TriggerCondition[pynenc.trigger.conditions.event.EventContext]

Condition based on system events.

Triggers a task when a specific event occurs, optionally filtered by event parameters.

Initialization

Create an event-based trigger condition.

Parameters:
  • event_code – Type of event this condition matches

  • required_params – Optional parameters that must exist with matching values in the event

context_type: ClassVar[type[pynenc.trigger.conditions.event.EventContext]]

None

property condition_id: str

Generate a unique ID for this event condition.

Returns:

A string ID based on the event code and required parameters

get_source_task_ids() set[str][source]
_to_json(app: pynenc.app.Pynenc) dict[str, Any][source]

Create a serializable representation of this condition.

Parameters:

app – Pynenc application instance for serializing complex arguments

Returns:

Dictionary with serialized condition data

classmethod _from_json(data: dict[str, Any], app: pynenc.app.Pynenc) pynenc.trigger.conditions.event.EventCondition[source]

Create an EventCondition from parsed JSON data.

Parameters:
  • data – Dictionary with condition data

  • app – Pynenc application instance for deserializing complex arguments

Returns:

A new EventCondition instance

Raises:

ValueError – If the data is invalid for this condition type

_is_satisfied_by(context: pynenc.trigger.conditions.event.EventContext) bool[source]

Check if this condition is satisfied by the given event context.

For an event condition to be satisfied:

  1. The event code must match

  2. All required parameters must exist in the payload with matching values

Parameters:

context – Event context to evaluate

Returns:

True if the condition is satisfied by the event

affects_task(task_id: str) bool[source]

Check if this condition is affected by a specific task.

Event conditions aren’t directly tied to specific tasks.

Parameters:

task_id – ID of the task to check

Returns:

Always False for event conditions