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
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)
def _func(*args, item=item, **kwargs): wrap_ = wrap.Wrap(func) wrap_func = getattr(wrap_, item) return wrap_func(*args, **kwargs)
def __rshift__(self, other): return wrap.Wrap(self).__rshift__(other)
def __or__(self, other): return wrap.Wrap(self) | other
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