def members(self): '''collect object members from incoming things''' with self._context(): mfilter, call = self._mfilter, self._call return self._xtend(ichain(imap( lambda x: mfilter(call, x), self._iterable, )))
def extract(self): '''extract object members from incoming things''' with self._context(): walk_ = self._extract call_, alt_, wrap_ = self._call, self._alt, self._wrapper return self._xtend(ichain(imap( lambda x: walk_(call_, alt_, wrap_, x), self._iterable, )))
def delay_map(self, wait): """ invoke call on each incoming thing after delay `wait` @param wait: time in seconds """ with self._context(): dm, call = self._delay_map, self._call return self._xtend(imap(lambda x: dm(x, wait, call), self._iterable))
def group(self): ''' group incoming things, optionally using current call for key function ''' call_, list_ = self._call, list with self._context(): return self._xtend(imap( lambda x: [x[0], list_(x[1])], groupby(self._iterable, call_) ))
def deepmembers(self): '''collect object members from incoming things and their bases''' _mf = self._mfilter _mz = lambda x: _mf(self._call, x) def _memfilters(thing, mz=_mz, gc=getcls, ci=ichain): return ci(imap(mz, ci([getmro((gc(thing))), [thing]]))) with self._context(): return self._xtend( ichain(imap(_memfilters, self._iterable)) )
def invoke(self, name): """ invoke method `name` on each incoming thing with passed arguments, keywords but return incoming thing instead if method returns `None` @param name: name of method """ with self._context(): invoke = self._invoke return self._xtend( imap(lambda x: invoke(x, caller=methodcaller(name, *self._args, **self._kw)), self._iterable) )
def delay_invoke(self, name, wait): """ invoke method `name` on each incoming thing with passed arguments, keywords after delay `wait` but return incoming thing instead if method returns `None` @param name: name of method @param wait: time in seconds """ with self._context(): di, mc = self._delay_invoke, methodcaller args, kw = self._args, self._kw return self._xtend(imap(lambda x: di(x, wait, mc(name, *args, **kw)), self._iterable))
def any(self): '''if `any` incoming things are `True`''' with self._context(): return self._append(any(imap(self._call, self._iterable)))
def quantify(self): '''how many times call is `True` for incoming things''' with self._context(): return self._append(sum(imap(self._call, self._iterable)))
def copy(self): """copy each incoming thing""" with self._context(): return self._xtend(imap(deepcopy, self._iterable))
def items(self): """invoke call on each mapping to get key, value pairs""" with self._context(): return self._xtend(starmap(self._call, ichain(imap(items, self._iterable))))
def map(self): """invoke call on each incoming thing""" with self._context(): return self._xtend(imap(self._call, self._iterable))
def _memfilters(thing, mz=_mz, gc=getcls, ci=ichain): return ci(imap(mz, ci([getmro((gc(thing))), [thing]])))