dantro.mixins.general module¶
This module implements general mixin classes for containers and groups
-
class
dantro.mixins.general.ForwardAttrsMixin[source]¶ Bases:
objectThis Mixin class forwards all calls to unavailable attributes to a certain other attribute, specified by
FORWARD_ATTR_TOclass variable.-
FORWARD_ATTR_TO= None¶
-
FORWARD_ATTR_ONLY= None¶
-
FORWARD_ATTR_EXCLUDE= ()¶
-
__getattr__(attr_name: str)[source]¶ Forward attributes that were not available in this class to some other attribute of the group or container.
- Parameters
attr_name (str) – The name of the attribute that was tried to be accessed but was not available in
self.- Returns
The attribute
attr_nameof getattr(self, self.FORWARD_ATTR_TO)
-
-
class
dantro.mixins.general.ForwardAttrsToDataMixin[source]¶ Bases:
dantro.mixins.general.ForwardAttrsMixinThis Mixin class forwards all calls to unavailable attributes to the
dataattribute (a property) and thus allows to replace all behaviour that is not implemented in the group or container with that of the stored data.-
FORWARD_ATTR_TO= 'data'¶
-
FORWARD_ATTR_EXCLUDE= ()¶
-
FORWARD_ATTR_ONLY= None¶
-
__getattr__(attr_name: str)¶ Forward attributes that were not available in this class to some other attribute of the group or container.
- Parameters
attr_name (str) – The name of the attribute that was tried to be accessed but was not available in
self.- Returns
The attribute
attr_nameof getattr(self, self.FORWARD_ATTR_TO)
-
_forward_attr_get_forwarding_target()¶ Get the object that the attribute call is to be forwarded to
-
_forward_attr_post_hook(attr)¶ Invoked before attribute forwarding occurs
-
_forward_attr_pre_hook(attr_name: str = None)¶ Invoked before attribute forwarding occurs
-