ModuleMix#
- class ModuleMix(*args, **kwargs)#
-
A module containing multiple other modules.
This can allow to combine modules to collect different sources, write multiple time in different manners, etc.
This is an abstract class and should be used as a base for creating specific mixes. This abstract class initialize every module in the mix. Mixes are intended to be instantiated with the class method
create().- __getattr__(name)#
Dispatch to base module if they have the attribute defined.
This gets called if __getattribute__ fails, ie the attribute is not defined on this instance.
- __init__(*args, **kwargs)#
- Return type:
None
- __weakref__#
list of weak references to the object
- apply(method: str, all: Literal[True], *args, select: dict[str, Any] | None = None, **kwargs) list[Any]#
- apply(method: str, all: Literal[False], *args, select: dict[str, Any] | None = None, **kwargs) Any
- apply(method: str, all: bool, *args, select: dict[str, Any] | None = None, **kwargs) Any | list[Any]
Get results from all or one of the base modules.
- Parameters:
- Return type:
- apply_all(method, *args, **kwargs)#
Get results from every base module.
Every output is put in a list if not already.
- apply_select(method, *args, select=None, **kwargs)#
Get result from a single base module.
Module is selected with
select_func, based on current module and data-manager state.
- classmethod create(bases, select_func=None)#
Create a new mix-class from base module.
- bases
Module types to mix.
- select_func
Function to select one of the base module depending on the current module state, and data-manager parameters. It receives the instance of the module mix and additional kwargs, and must return the class-name of one of the base module.
- select(**kwargs)#
Return the module to select under current module and data-manager state.
- Parameters:
kwargs – Will be passed to the selection function.
- Return type:
T_Mod
- classmethod set_select(select_func)#
Set the selection function.
- select_func
Function to select one of the base module depending on the current module state, and data-manager parameters. It receives the instance of the module mix and additional kwargs, and must return the class-name of one of the base module.
- Parameters:
select_func (abc.Callable[..., str])
- setup()#
Initialize module.
- Return type:
None