コード例 #1
0
ファイル: spaces.py プロジェクト: lcrees/appspace
    def factory(label, manager, *args):
        '''
        factory for manager

        @param label: label for manager
        '''
        # build manager
        manager = manager(label)
        # register things in manager
        exhaust(starmap(lambda x, y: manager.set(y, x), iter(args)))
        return manager
コード例 #2
0
ファイル: core.py プロジェクト: lcrees/stuf
 def _populate(self, past, future, _map=starmap, _items=items):
     def _coro(key, value, new=self._new):
         if isinstance(value, (Mapping, Sequence)):
             # see if stuf can be converted to nested stuf
             trial = new(self.default_factory, value)
             if len(trial) > 0:
                 future[key] = trial
             else:
                 future[key] = value
         else:
             future[key] = value
     exhaust(_map(_coro, _items(past)))
コード例 #3
0
ファイル: core.py プロジェクト: lcrees/stuf
    def _populate(self, past, future, _map=starmap, _items=items):
        def _coro(key, value, new=self._new):
            if isinstance(value, (Mapping, Sequence)):
                # see if stuf can be converted to nested stuf
                trial = new(self.default_factory, value)
                if len(trial) > 0:
                    future[key] = trial
                else:
                    future[key] = value
            else:
                future[key] = value

        exhaust(_map(_coro, _items(past)))
コード例 #4
0
ファイル: base.py プロジェクト: lcrees/stuf
 def _populate(cls, past, future, _is=isinstance, m=starmap, _i=items):
     def _coro(key, value, new=cls._new, _is=_is):
         if _is(value, (Sequence, Mapping)) and not _is(value, strings):
             # see if stuf can be converted to nested stuf
             trial = new(value)
             if len(trial) > 0:
                 future[key] = trial
             else:
                 future[key] = value
         else:
             future[key] = value
     exhaust(m(_coro, _i(past)))
     return cls._postpopulate(future)
コード例 #5
0
ファイル: base.py プロジェクト: lcrees/stuf
    def _populate(cls, past, future, _is=isinstance, m=starmap, _i=items):
        def _coro(key, value, new=cls._new, _is=_is):
            if _is(value, (Sequence, Mapping)) and not _is(value, strings):
                # see if stuf can be converted to nested stuf
                trial = new(value)
                if len(trial) > 0:
                    future[key] = trial
                else:
                    future[key] = value
            else:
                future[key] = value

        exhaust(m(_coro, _i(past)))
        return cls._postpopulate(future)
コード例 #6
0
ファイル: patterns.py プロジェクト: lcrees/callchain
 def _key(cls, label, manager):
     try:
         # lazily load key
         key = cls.key
         if isinstance(key, strings):
             key = lazyimport(key)
         # register class key
         ez_register = manager.ez_register
         ez_register(ANamespace, label, key)
         exhaust(imap(
             lambda x: ez_register(KService, x, label),
             iter(key.names(True)),
         ))
     except AttributeError:
         key = manager.key(ANamespace, label)