コード例 #1
0
ファイル: dispatcher.py プロジェクト: ed-aicradle/monotone
 def register_for(self, callback, types, topics, sources, fast=True):
     if types is None: types = [ALL]
     if topics is None: topics = [ALL]
     if sources is None: sources = [ALL]
     callback = CollectableCallback(callback, fast)
     for event_type in types:
         self.types.setdefault(event_type, {})[callback.guid] = callback
     for source in sources:
         self.sources.setdefault(source, {})[callback.guid] = callback
     for topic in topics:
         self.topics.setdefault(topic, {})[callback.guid] = callback
     callback.types = types
     callback.topics = topics
     callback.sources = sources
     return callback.guid
コード例 #2
0
ファイル: dispatcher.py プロジェクト: mcruse/monotone
 def register_for(self, callback, types, topics, sources, fast = True):
     if types is None: types = [ALL]
     if topics is None: topics = [ALL]
     if sources is None: sources = [ALL]
     callback = CollectableCallback(callback, fast)
     for event_type in types:
         self.types.setdefault(event_type, {})[callback.guid] = callback
     for source in sources:
         self.sources.setdefault(source, {})[callback.guid] = callback
     for topic in topics:
         self.topics.setdefault(topic, {})[callback.guid] = callback
     callback.types = types
     callback.topics = topics
     callback.sources = sources
     return callback.guid
コード例 #3
0
ファイル: dispatcher.py プロジェクト: ed-aicradle/monotone
 def unregister(self, guid):
     callback = CollectableCallback.get_callback(guid)
     for event_type in callback.types:
         try:
             del (self.types[event_type][guid])
         except KeyError:
             pass
     for topic in callback.topics:
         try:
             del (self.topics[topic][guid])
         except KeyError:
             pass
     for source in callback.sources:
         try:
             del (self.sources[source][guid])
         except KeyError:
             pass
     return
コード例 #4
0
ファイル: dispatcher.py プロジェクト: mcruse/monotone
 def unregister(self, guid):
     callback = CollectableCallback.get_callback(guid)
     for event_type in callback.types:
         try: 
             del(self.types[event_type][guid])
         except KeyError:
             pass
     for topic in callback.topics:
         try: 
             del(self.topics[topic][guid])
         except KeyError:
             pass
     for source in callback.sources:
         try: 
             del(self.sources[source][guid])
         except KeyError:
             pass
     return