pynenc.trigger.arguments.arguments_common

Module Contents

Classes

SerializableCallable

Wrapper for callable objects that enables serialization and deserialization.

API

exception pynenc.trigger.arguments.arguments_common.NonModuleLevelFunctionError[source]

Bases: ValueError

Raised when a function provided for argument filtering is not defined at module level.

Module-level functions are required for proper serialization and deserialization of argument filters.

Initialization

Initialize self. See help(type(self)) for accurate signature.

class pynenc.trigger.arguments.arguments_common.SerializableCallable(func: collections.abc.Callable)[source]

Wrapper for callable objects that enables serialization and deserialization.

This class stores the module and name of a function to allow importing it later.

Initialization

Initialize with a function reference.

Parameters:

func – The callable to wrap

Raises:

NonModuleLevelFunctionError – If the function is not at module level

callable_id() str[source]

Get a unique identifier for the callable.

Returns:

A string representing the callable’s module and name

__call__(*args: Any, **kwargs: Any) Any[source]

Call the wrapped function.

Parameters:
  • args – Positional arguments to pass to the function

  • kwargs – Keyword arguments to pass to the function

Returns:

The result of the function call

to_json() str[source]

Serialize this callable to a JSON string.

Returns:

JSON string representation of this callable

classmethod from_json(json_str: str) pynenc.trigger.arguments.arguments_common.SerializableCallable[source]

Create a SerializableCallable instance from a JSON string.

Parameters:

json_str – JSON string containing serialized callable data

Returns:

A new SerializableCallable instance