Skip to content

_containers

Full documentation pages are generated for docstring reference only and may contain symbols imported from other modules. Imported symbols are not distinguished from locally defined symbols and will appear in any module that they are imported into. For better information on where symbols should be imported from, review the sourcecode on the github.

FoSpy.blocks._containers

SimpleWrapper

Wrapper for attaching methods and attributes to simple data types that don't support it. Most method or attribute calls are passed through to the wrapped value, but some methods or private attributes are attached when setting a SimpleWrapper as attribute for a SingleBlock or ListBlock.

Source code in FoSpy/blocks/_containers.py
class SimpleWrapper:
    """
    Wrapper for attaching methods and attributes to simple data types that don't
    support it. Most method or attribute calls are passed through to the wrapped
    value, but some methods or private attributes are attached when setting a
    `SimpleWrapper` as attribute for a `SingleBlock` or `ListBlock`.
    """
    def __init__(self, value):
        self._value = value

    def __iter__(self):
        return self._value.__iter__()

    def __str__(self):
        return str(self._value)

    def __repr__(self):
        return repr(self._value)

    def __eq__(self, other):
        return self._value == other

    def __call__(self):
        return self._value

    def __getattr__(self, name):
        return getattr(self._value, name)

    def __getitem__(self, key):
        return self._value.__getitem__(key)

    def __setitem__(self, key, val):
        return self._value.__setitem__(key, val)

    def __int__(self):
        return int(self._value)

    def __float__(self):
        return float(self._value)

_value instance-attribute

_value = value

__call__

__call__()
Source code in FoSpy/blocks/_containers.py
def __call__(self):
    return self._value

__eq__

__eq__(other)
Source code in FoSpy/blocks/_containers.py
def __eq__(self, other):
    return self._value == other

__float__

__float__()
Source code in FoSpy/blocks/_containers.py
def __float__(self):
    return float(self._value)

__getattr__

__getattr__(name)
Source code in FoSpy/blocks/_containers.py
def __getattr__(self, name):
    return getattr(self._value, name)

__getitem__

__getitem__(key)
Source code in FoSpy/blocks/_containers.py
def __getitem__(self, key):
    return self._value.__getitem__(key)

__init__

__init__(value)
Source code in FoSpy/blocks/_containers.py
def __init__(self, value):
    self._value = value

__int__

__int__()
Source code in FoSpy/blocks/_containers.py
def __int__(self):
    return int(self._value)

__iter__

__iter__()
Source code in FoSpy/blocks/_containers.py
def __iter__(self):
    return self._value.__iter__()

__repr__

__repr__()
Source code in FoSpy/blocks/_containers.py
def __repr__(self):
    return repr(self._value)

__setitem__

__setitem__(key, val)
Source code in FoSpy/blocks/_containers.py
def __setitem__(self, key, val):
    return self._value.__setitem__(key, val)

__str__

__str__()
Source code in FoSpy/blocks/_containers.py
def __str__(self):
    return str(self._value)

SubContainer

A simple container for storing hidden or unexpected attributes of a SingleBlock

Values are only assigned directly to SingleBlock attributes if they are an expected property. Otherwise they are assigned to a SubContainer at SingleBlock.ext. Also used for SingleBlock._meta.

Example Usage:

class SingleBlock:
    ... 
    def __setattr__(self, name, value):
        ... 
        if name not in expected:
            return setattr(self.ext, name, value)

Source code in FoSpy/blocks/_containers.py
class SubContainer:
    """
    A simple container for storing hidden or unexpected attributes of a
    `SingleBlock`

    Values are only assigned directly to `SingleBlock` attributes if they are an
    expected property. Otherwise they are assigned to a `SubContainer` at
    `SingleBlock.ext`. Also used for `SingleBlock._meta`.

    Example Usage:
    ```
    class SingleBlock:
        ... 
        def __setattr__(self, name, value):
            ... 
            if name not in expected:
                return setattr(self.ext, name, value)
    ```
    """
    def __init__(self):
        pass
    def __iter__(self):
        return iter(self.__dict__)

__init__

__init__()
Source code in FoSpy/blocks/_containers.py
def __init__(self):
    pass

__iter__

__iter__()
Source code in FoSpy/blocks/_containers.py
def __iter__(self):
    return iter(self.__dict__)