Esempio n. 1
0
def _wrap_task(obj):
    """ wrap up an object or sequence of objects"""
    if isinstance(obj, task.Task):
        return _wrap_task(wrap.Wrap(obj))
    elif isinstance(obj, (list, tuple)):
        return [_wrap_task(x) for x in obj]
    assert isinstance(obj, wrap.Wrap), "non_wrap returned by _wrap_task"
    return obj
Esempio n. 2
0
    def wrap(self, *args, **kwargs) -> "wrap.Wrap":
        """
        Instantiate a Wrap instance from this task.

        Args and kwargs are passed to Wrap constructor.

        Returns
        -------
        Wrap
        """
        return wrap.Wrap(self, *args, **kwargs)
Esempio n. 3
0
 def _func(*args, item=item, **kwargs):
     wrap_ = wrap.Wrap(func)
     wrap_func = getattr(wrap_, item)
     return wrap_func(*args, **kwargs)
Esempio n. 4
0
 def __rshift__(self, other):
     return wrap.Wrap(self).__rshift__(other)
Esempio n. 5
0
 def __or__(self, other):
     return wrap.Wrap(self) | other
Esempio n. 6
0
 def __getattr__(self, item):
     # if the item is supported by _Task class return wrapped task
     if item in wrap.Wrap._wrap_funcs:
         return getattr(wrap.Wrap(self), item)
     else:
         raise AttributeError