briann.utilities package
Submodules
briann.utilities.callbacks module
- class briann.utilities.callbacks.CallbackManager[source]
Bases:
objectThis class allows to add callbacks to attribute setters and method calls.
- __setattr__with_callbacks(obj, name, value) None
Sets an attribute and calls any callbacks associated with it.
- Parameters:
target_class (Any) – The class of the instance.
obj (Any) – The instance to set the attribute on.
name (str) – The name of the attribute to set.
value (Any) – The value to set the attribute to.
- Return type:
None
- _class_to_regular_setattr = {}
- _obj_to_attribute_name_to_callbacks = {}
- add_callback_to_attribute(target_instance: Any, attribute_name: str, callback: callable) None[source]
Adds a callback to an attribute setter of a specific instance of a class. The callback must have the signature: callback(obj: Any, name: str, value: Any) where obj is the instance, name is the attribute name, and value is the new value. Any returned values from the callback are ignored.
- Parameters:
target_class (Any) – The class of the instance.
target_instance (Any) – The instance to inspect.
attribute_name (str) – The name of the attribute to inspect.
callback (callable) – The callback to call when the attribute is set. The callback must have the signature: callback(obj: Any, name: str, value: Any), where obj is the instance on which the attribute setter is called, name is the name of the attribute and value is the new value to be assigned to the attribute.
- Return type:
None
- add_callback_to_method(method_name: str, callback: callable) None[source]
Adds a callback to a method of a specific instance of a class.
- Parameters:
target_instance (Any) – The instance to inspect.
method_name (str) – The name of the method to inspect.
callback (callable) – The callback to call when the method is called. The callback must have the signature: callback(obj: Any, args, kwargs), where obj is the object in which the method is called, and args and kwargs are the positional and key-word arguments of the method, respectively. For arguments that are optional for the method, the default value assigned to the corresponding callback’s argument takes priority over that asigned to the method’s argument. Any returned values from the callback are ignored.
- Return type:
None
briann.utilities.core module
briann.utilities.file_management module
briann.utilities.playground module
- class briann.utilities.playground.Observer(on_separate_thread: bool = False)[source]
Bases:
object- class Entry(method_name, argument_names, callback, event, required_argument_values)[source]
Bases:
object