yggdrasil.communication.filters package

Submodules

yggdrasil.communication.filters.DirectFilter module

class yggdrasil.communication.filters.DirectFilter.DirectFilter(*args, **kwargs)[source]

Bases: yggdrasil.communication.filters.FilterBase.FilterBase

Class that always passes messages.

evaluate_filter(x)[source]

Call filter on the provided message.

Parameters

x (object) – Message object to filter.

Returns

True if the message will pass through the filter, False otherwise.

Return type

bool

classmethod get_testing_options()[source]

Get testing options for the filter class.

Returns

Mutiple dictionaries of keywords and messages that will

pass/fail for those keywords.

Return type

list

yggdrasil.communication.filters.FilterBase module

class yggdrasil.communication.filters.FilterBase.FilterBase(*args, **kwargs)[source]

Bases: yggdrasil.components.ComponentBase

Base class for message filters.

Parameters

initial_state (dict, optional) – Dictionary of initial state variables that should be set when the filter is created.

__call__(x)[source]

Call filter on the provided message.

Parameters

x (object) – Message object to filter.

Returns

True if the message will pass through the filter, False otherwise.

Return type

bool

evaluate_filter(x)[source]

Call filter on the provided message.

Parameters

x (object) – Message object to filter.

Returns

True if the message will pass through the filter, False otherwise.

Return type

bool

yggdrasil.communication.filters.FunctionFilter module

class yggdrasil.communication.filters.FunctionFilter.FunctionFilter(*args, **kwargs)[source]

Bases: yggdrasil.communication.filters.FilterBase.FilterBase

Class for filtering messages based on a provided function using Python syntax.

Parameters

function (func) – The handle for a callable Python object (e.g. function) that should be used to determine if a message should be filtered or a string of the form “<function file>:<function name>” identifying a function where “<function file>” is the module or Python file containing the function and “<function name>” is the name of the function. The function should take the message as input and return a boolean, True if the message should pass through the filter, False if it should not.

evaluate_filter(x)[source]

Call filter on the provided message.

Parameters

x (object) – Message object to filter.

Returns

True if the message will pass through the filter, False otherwise.

Return type

bool

classmethod get_testing_options()[source]

Get testing options for the filter class.

Returns

Mutiple dictionaries of keywords and messages that will

pass/fail for those keywords.

Return type

list

yggdrasil.communication.filters.StatementFilter module

class yggdrasil.communication.filters.StatementFilter.StatementFilter(*args, **kwargs)[source]

Bases: yggdrasil.communication.filters.FilterBase.FilterBase

Class for filtering messages based on a provided statement using Python syntax.

Parameters

statement (str) – Python statement in terms of the message as represented by the string “%x%” that should evaluate to a boolean, True if the message should pass through the filter, False if it should not. The statement should only use a limited set of builtins and the math library (See yggdrasil.tools.safe_eval). If more complex relationships are required, use the FunctionFilter class.

statement

Python statement that will be evaluated to determine if messages should or should not pass the filter.

Type

str

evaluate_filter(x)[source]

Call filter on the provided message.

Parameters

x (object) – Message object to filter.

Returns

True if the message will pass through the filter, False otherwise.

Return type

bool

classmethod get_testing_options()[source]

Get testing options for the filter class.

Returns

Mutiple dictionaries of keywords and messages that will

pass/fail for those keywords.

Return type

list

Module contents