taukit/base/metacls.py
def _setattribute(self, attr, value, on_component=True):
    """Set attribute on instance or on a component.

    Parameters
    ----------
    attr : str
        Attribute name.
    value : any
        Value to assign.
    on_component : bool or str
        Should value be assigned to a first component with
        given attribute or should be assigned at the instance level.
        If is `str` then attribute is set on a component with a given name.

    Raises
    ------
    AttributeError
        If `on_component=True` and no component with given `attr` was found.
    """
    if not on_component:
        setattr(self, attr, value)
        return
    components = \
        [ *(getattr(self, '__components') if '__components' in dir(self) else {}).items() ]
    bases = (self.__class__, *self.__class__.__bases__)
    for base in bases:
        components_attr = '_'+base.__name__+'__components'
        components = [ *components, *getattr(base, components_attr, {}).items() ]
    for _, component in components:
        if hasattr(component, attr):
            setattr(component, attr, value)
            return
    raise AttributeError(f"No component with '{attr}' attribute was found")
Set attribute on instance or on a component.

    Parameters
    ----------
    attr : str
        Attribute name.
    value : any
        Value to assign.
    on_component : bool or str
        Should value be assigned to a first component with
        given attribute or should be assigned at the instance level.
        If is `str` then attribute is set on a component with a given name.

    Raises
    ------
    AttributeError
        If `on_component=True` and no component with given `attr` was found.
    
Set attribute on instance or on a component.
Parameters

attr : str
Attribute name.
value : any
Value to assign.
on_component : bool or str
Should value be assigned to a first component with
given attribute or should be assigned at the instance level.
If is `str` then attribute is set on a component with a given name.

Raises

AttributeError
If `on_component=True` and no component with given `attr` was found.
Set attribute on instance or on a component . Parameters attr : str Attribute name . value : any Value to assign . on_component : bool or str Should value be assigned to a first component with given attribute or should be assigned at the instance level . If is ` str ` then attribute is set on a component with a given name . Raises AttributeError If ` on_component = True ` and no component with given ` attr ` was found .
def _setattribute(self, attr, value, on_component=True):
    if not on_component:
        setattr(self, attr, value)
        return
    components = \
        [ *(getattr(self, '__components') if '__components' in dir(self) else {}).items() ]
    bases = (self.__class__, *self.__class__.__bases__)
    for base in bases:
        components_attr = '_'+base.__name__+'__components'
        components = [ *components, *getattr(base, components_attr, {}).items() ]
    for _, component in components:
        if hasattr(component, attr):
            setattr(component, attr, value)
            return
    raise AttributeError(f"No component with '{attr}' attribute was found")
def _setattribute ( self , attr , value , on_component = True ) : if not on_component : setattr ( self , attr , value ) return components = [ * ( getattr ( self , '__components' ) if '__components' in dir ( self ) else { } ) . items ( ) ] bases = ( self . __class__ , * self . __class__ . __bases__ ) for base in bases : components_attr = '_' + base . __name__ + '__components' components = [ * components , * getattr ( base , components_attr , { } ) . items ( ) ] for _ , component in components : if hasattr ( component , attr ) : setattr ( component , attr , value ) return raise AttributeError ( f"No component with '{attr}' attribute was found" )
Set attribute on instance or on a component.
Set attribute on instance or on a component .
"""Set attribute on instance or on a component.

    Parameters
    ----------
    attr : str
        Attribute name.
    value : any
        Value to assign.
    on_component : bool or str
        Should value be assigned to a first component with
        given attribute or should be assigned at the instance level.
        If is `str` then attribute is set on a component with a given name.

    Raises
    ------
    AttributeError
        If `on_component=True` and no component with given `attr` was found.
    """
self
attr
value
on_component