Ejemplo n.º 1
0
 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,
         )))
Ejemplo n.º 2
0
 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,
         )))
Ejemplo n.º 3
0
    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))
Ejemplo n.º 4
0
 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_)
         ))
Ejemplo n.º 5
0
 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))
         )
Ejemplo n.º 6
0
    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)
            )
Ejemplo n.º 7
0
    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))
Ejemplo n.º 8
0
 def any(self):
     '''if `any` incoming things are `True`'''
     with self._context():
         return self._append(any(imap(self._call, self._iterable)))
Ejemplo n.º 9
0
 def quantify(self):
     '''how many times call is `True` for incoming things'''
     with self._context():
         return self._append(sum(imap(self._call, self._iterable)))
Ejemplo n.º 10
0
 def copy(self):
     """copy each incoming thing"""
     with self._context():
         return self._xtend(imap(deepcopy, self._iterable))
Ejemplo n.º 11
0
 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))))
Ejemplo n.º 12
0
 def map(self):
     """invoke call on each incoming thing"""
     with self._context():
         return self._xtend(imap(self._call, self._iterable))
Ejemplo n.º 13
0
 def _memfilters(thing, mz=_mz, gc=getcls, ci=ichain):
     return ci(imap(mz, ci([getmro((gc(thing))), [thing]])))