Commits

Lynn Rees committed 6907308

- update

  • Participants
  • Parent commits 72fe0b4
  • Branches pu

Comments (0)

Files changed (12)

callchain/apps.py

+
+        
+        
+class LookupsMixin(local):
+
+    '''lookup mixins'''
+
+    _choice = lazier(choice)
+    _clsname = lazier(clsname)
+    _contains = lazier(operator.contains)
+    _counter = lazier(support.Counter)
+    _deek = lazier(deque)
+    _filterfalse = lazier(support.filterfalse)
+    _fsum = lazier(fsum)
+    _groupby = lazier(itertools.groupby)
+    _ichain = lazier(itertools.chain.from_iterable)
+    _ifilter = lazier(support.ifilter)
+    _imap = lazier(support.imap)
+    _ireduce = lazier(functools.reduce)
+    _islice = lazier(itertools.islice)
+    _items = lazier(support.items)
+    _iterz = lazier(iter)
+    _join = lazier(itertools.chain)
+    _len = lazier(len)
+    _list = lazier(list)
+    _max = lazier(max)
+    _methodcaller = lazier(methodcaller)
+    _min = lazier(min)
+    _next = lazier(next)
+    _partial = lazier(functools.partial)
+    _range = lazier(support.range)
+    _repeat = lazier(itertools.repeat)
+    _reversed = lazier(reversed)
+    _sample = lazier(sample)
+    _shuffle = lazier(shuffle)
+    _sleep = lazier(time.sleep)
+    _sorted = lazier(sorted)
+    _split = lazier(itertools.tee)
+    _starmap = lazier(itertools.starmap)
+    _sum = lazier(sum)
+    _truediv = lazier(operator.truediv)
+    _zip = lazier(zip)
+
+    @lazy
+    def _getr(self):
+        '''local getter'''
+        return self._partial(local.__getattribute__, self)
+
+    @lazy
+    def _setr(self):
+        '''local setter'''
+        return self._partial(local.__setattr__, self)
+
+    @lazy
+    def _delr(self):
+        '''local deleter'''
+        return self._partial(local.__delattr__, self)
+    
+        self.ez_register(KInternalSettings, label, Settings)
+        self.ez_register(KExternalSettings, label, Settings)
+        self.ez_register(KQueue, label, twoq)
+        self.ez_register(KPorting, label, port)
+        self.ez_register(KEventRegistry, label, EventRegistry)

callchain/base.py

 
 from stuf.six import items
 from stuf import frozenstuf
-from appspace.keys import AppLookupError, NoAppError
+from appspace.keys import AppLookupError, NoApp
 from stuf.utils import getcls, either, lazy, lazybase, exhaustmap
 
 
                 # verify namespace
                 _M.namespace(label)
             except AppLookupError:
-                raise NoAppError(label)
+                raise NoApp(label)
             else:
                 # temporarily swap current label
                 _M._current = label

callchain/branch.py

 # -*- coding: utf-8 -*-
 '''root chain mixins'''
 
-from appspace import NoAppError
+from appspace import NoApp
 
 from callchain.base import ResetLocalMixin, CoreMixin
 from callchain.mixins import BranchMixin, EventBranchMixin, ChainMixin,\
         try:
             return super(ChainletMixin, self)._load(label)
         # ...or revert to root chain
-        except NoAppError:
+        except NoApp:
             return getattr(self.back(), label)
 
     def _syncback(self, key, value):

callchain/chainlets/registry.py

+# -*- coding: utf-8 -*-
+'''callchain event registry'''
+
+from stuf.six import u
+
+from appspace.registry import Registry
+from callchain.keys.event import EEvent
+
+
+class EventRegistry(Registry):
+
+    '''event registry'''
+
+    __slots__ = ('_root', '_key')
+
+    def __init__(self, label, key=EEvent):
+        '''
+        init
+
+        @param label: label for event registry
+        @param key: default key for event registry (default: EEvent)
+        '''
+        super(EventRegistry, self).__init__(label, key)
+
+    def event(self, label):
+        '''
+        create or fetch event
+
+        @param event: event label
+        '''
+        return self._unlazy(label, self._key, self.key(self._key, label))
+
+    def events(self, key):
+        '''
+        fetch things bound to event
+
+        @param label: event label
+        '''
+        return self.subscriptions(self._key, key)
+
+    def get(self, key):
+        '''
+        fetch thing from events
+
+        @param key: event key
+        '''
+        return self.lookup1(self._key, key)
+
+    def set(self, key, call):
+        '''
+        bind thing to event
+
+        @param label: event label
+        @param key: event key
+        @param call: some thing
+        '''
+        self.register([self._key], key, call)
+
+    def on(self, key, thing):
+        '''
+        bind thing to event
+
+        @param label: event label
+        @param key: event key
+        @param call: some thing
+        '''
+        self.subscribe(self._key, key, thing.commit)
+        self.register([self._key], key, u(''), thing)
+
+    def unevent(self, label):
+        '''
+        drop event
+
+        @param event: event label
+        '''
+        self.E.unkey(self._key, self.event(label))
+
+    def unset(self, label):
+        '''
+        clear all callables bound to event
+
+        @param event: event label
+        '''
+        self.ez_unsubscribe(self._key, self.event(label))

callchain/keys/base.py

 # -*- coding: utf-8 -*-
 '''callchain reset keys'''
 
-from appspace.keys import AppspaceKey, Attribute, ConfigurationError
+from appspace.keys import AppspaceKey, Attribute
 
 
 class KRoutes(AppspaceKey):
 
     defaults = Attribute('default settings by their lonesome')
     required = Attribute('required settings by their lonesome')
-
-
-class NoService(ConfigurationError):
-
-    '''no service'''

callchain/keys/chainlet.py

 # -*- coding: utf-8 -*-
 '''callchain contrib keys'''
 
-from appspace import AppspaceKey, Attribute
+from appspace import AppspaceKey, Attribute, AppLookupError
 
 from callchain.keys.core import KBranch
 
 
+class NoService(AppLookupError):
+
+    '''no service'''
+
+
 class KChainlet(KBranch):
 
     '''service key'''

callchain/keys/filter.py

 # -*- coding: utf-8 -*-
 '''filtering services keys'''
 
-from callchain.keys.core import KChainlet
+from callchain.keys.chainlet import KChainlet
 
 
 class KCollect(KChainlet):

callchain/keys/map.py

 # -*- coding: utf-8 -*-
 '''mapping services keys'''
 
-from callchain.keys.core import KChainlet
+from callchain.keys.chainlet import KChainlet
 
 
 class KDelay(KChainlet):

callchain/keys/order.py

 # -*- coding: utf-8 -*-
 '''ordering services keys'''
 
-from callchain.keys.core import KChainlet
+from callchain.keys.chainlet import KChainlet
 
 
 class KRandom(KChainlet):

callchain/keys/reduce.py

 # -*- coding: utf-8 -*-
 '''reducing service keys'''
 
-from callchain.keys.core import KChainlet
+from callchain.keys.chainlet import KChainlet
 
 
 class KMath(KChainlet):

callchain/keys/settings.py

 # -*- coding: utf-8 -*-
 '''callchain settings keys'''
 
-from appspace.keys import AppspaceKey
+from appspace.keys import ANamespace
 
 
-class KSettings(AppspaceKey):
+class KSettings(ANamespace):
 
     '''settings key'''
 
     '''external required settings key'''
 
 
-class KSettingsManager(AppspaceKey):
+class KSettingsManager(ANamespace):
 
     '''settings manager key'''
 

callchain/registry.py

 # -*- coding: utf-8 -*-
 '''callchain managers'''
 
-from stuf.six import u
 from stuf.utils import lazy
-from twoq import port, twoq
 from appspace import Manager
 from appspace.keys import AApp
 from appspace.keys import ConfigurationError
 
-from appspace.registry import Registry
-from callchain.keys.event import EEvent
-from callchain.settings import Settings
 from callchain.keys.base import KEventRegistry
 from callchain.keys.chainlet import KChainlet, KQueue, KPorting
 from callchain.keys.settings import KInternalSettings, KExternalSettings
 
 
-class EventRegistry(Registry):
-
-    '''event registry'''
-
-    __slots__ = ('_root', '_key')
-
-    def __init__(self, label, key=EEvent):
-        '''
-        init
-
-        @param label: label for event registry
-        @param key: default key for event registry (default: EEvent)
-        '''
-        super(EventRegistry, self).__init__(label, key)
-
-    def event(self, label):
-        '''
-        create or fetch event
-
-        @param event: event label
-        '''
-        return self._unlazy(label, self._key, self.key(self._key, label))
-
-    def events(self, key):
-        '''
-        fetch things bound to event
-
-        @param label: event label
-        '''
-        return self.subscriptions(self._key, key)
-
-    def get(self, key):
-        '''
-        fetch thing from events
-
-        @param key: event key
-        '''
-        return self.lookup1(self._key, key)
-
-    def set(self, key, call):
-        '''
-        bind thing to event
-
-        @param label: event label
-        @param key: event key
-        @param call: some thing
-        '''
-        self.register([self._key], key, call)
-
-    def on(self, key, thing):
-        '''
-        bind thing to event
-
-        @param label: event label
-        @param key: event key
-        @param call: some thing
-        '''
-        self.subscribe(self._key, key, thing.commit)
-        self.register([self._key], key, u(''), thing)
-
-    def unevent(self, label):
-        '''
-        drop event
-
-        @param event: event label
-        '''
-        self.E.unkey(self._key, self.event(label))
-
-    def unset(self, label):
-        '''
-        clear all callables bound to event
-
-        @param event: event label
-        '''
-        self.ez_unsubscribe(self._key, self.event(label))
-
-
 class ChainRegistry(Manager):
 
     '''chain registry'''
         @param key: default key for appspace (default: AApp)
         '''
         super(ChainRegistry, self).__init__(label, key)
-        self.ez_register(KInternalSettings, label, Settings)
-        self.ez_register(KExternalSettings, label, Settings)
-        self.ez_register(KQueue, label, twoq)
-        self.ez_register(KPorting, label, port)
-        self.ez_register(KEventRegistry, label, EventRegistry)
 
     @lazy
     def internal_settings(self):