briann.utilities package

Submodules

briann.utilities.callbacks module

class briann.utilities.callbacks.CallbackManager[source]

Bases: object

This 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

class briann.utilities.core.Adapter[source]

Bases: object

briann.utilities.file_management module

briann.utilities.file_management.map_path_to_os(path: str) str[source]

Maps the given folder path to the appropriate format for the current operating system. :param folder_path: The folder path to map. :return: The mapped folder path. :rtype: str

briann.utilities.playground module

class briann.utilities.playground.A(x)[source]

Bases: object

property x
class briann.utilities.playground.B(x)[source]

Bases: A

callback(name, value)[source]
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

trace_function(frame, event, arg, indent=[0])[source]
class briann.utilities.playground.One(x)[source]

Bases: object

class briann.utilities.playground.Two(one)[source]

Bases: object

briann.utilities.random module

class briann.utilities.random.IndexSampler(instance_count: int, seed: int = None)[source]

Bases: Sampler[int]

property instance_count: int
property seed: int
class briann.utilities.random.StatelessRandom[source]

Bases: object

linear_congruential_generator(modulo: int, seed: int, count: int) ndarray[source]
pseudo_uniform(upper_bound: float, seed: int, count: int) ndarray[source]
shuffle(seed: int) List[int][source]

Module contents