chainlet.wrapper module¶
-
class
chainlet.wrapper.
WrapperMixin
(slave)¶ Bases:
object
Mixin for
ChainLink
s that wrap other objectsApply as a mixin via multiple inheritance:
class SimpleWrapper(WrapperMixin, ChainLink): /"/"/"Chainlink that calls ``slave`` for each chunk/"/"/" def __init__(self, slave): super().__init__(slave=slave) def chainlet_send(self, value): value = self.__wrapped__.send(value)
Wrappers bind their slave to
__wrapped__
, as is the Python standard, and also expose them via theslave
property for convenience.Additionally, subclasses provide the
wraplet()
to create factories of wrappers. This requires__init_slave__()
to be defined.-
slave
¶
-
classmethod
wraplet
(*cls_args, **cls_kwargs)¶ Create a factory to produce a Wrapper from a slave factory
Parameters: - cls_args – positional arguments to provide to the Wrapper class
- cls_kwargs – keyword arguments to provide to the Wrapper class
Returns: cls_wrapper_factory = cls.wraplet(*cls_args, **cls_kwargs) link_factory = cls_wrapper_factory(slave_factory) slave_link = link_factory(*slave_args, **slave_kwargs)
-
-
chainlet.wrapper.
getname
(obj)¶ Return the most qualified name of an object
Parameters: obj – object to fetch name Returns: name of obj