pysap.base.observable#

class SignalObject[source]#

Bases: object

Dummy class for signals.

class Observable(signals)[source]#

Bases: object

Base class for observable classes.

This class defines a simple interface to add or remove observers on an object.

add_observer(signal, observer)[source]#

Add an observer to the object. Raise an exception if the signal is not allowed.

Parameters
  • signal (str) – a valid signal.

  • observer (callable) – a function that will be called when the signal is emitted.

remove_observer(signal, observer)[source]#

Remove an observer from the object. Raise an eception if the signal is not allowed.

Parameters
  • signal (str) – a valid signal.

  • observer (callable) – an obervation function to be removed.

notify_observers(signal, **kwargs)[source]#

Notify observers of a given signal.

Parameters
  • signal (str) – a valid signal.

  • kwargs (dict) – the parameters that will be sent to the observers.

Returns

out – Fasle if a notification is in progress, otherwise True.

Return type

bool

_get_allowed_signals()[source]#

Events allowed for the current object.

property allowed_signals#

Events allowed for the current object.

_is_allowed_signal(signal)[source]#

Check if a signal is valid. Raise an exception if the signal is not allowed.

Parameters

signal (str) – a signal.

_add_observer(signal, observer)[source]#

Assocaite an observer to a valid signal.

Parameters
  • signal (str) – a valid signal.

  • observer (callable) – an obervation function.

_remove_observer(signal, observer)[source]#

Remove an observer to a valid signal.

Parameters
  • signal (str) – a valid signal.

  • observer (callable) – an obervation function to be removed.