Commit 75cb38b5 by Chris Morgan

A bit more cleaning up of registry.py.

parent 4570991a
...@@ -22,33 +22,20 @@ world = threading.local() ...@@ -22,33 +22,20 @@ world = threading.local()
world._set = False world._set = False
class CallbackDict(dict): def _function_matches(one, other):
def _function_matches(self, one, other): return (one.func_code.co_filename == other.func_code.co_filename and
params = 'co_filename', 'co_firstlineno' one.func_code.co_firstlineno == other.func_code.co_firstlineno)
matches = []
for param in params:
one_got = getattr(one.func_code, param)
other_got = getattr(other.func_code, param)
matches.append(one_got == other_got)
return all(matches)
class CallbackDict(dict):
def append_to(self, where, when, function): def append_to(self, where, when, function):
found = False if not any(_function_matches(o, function) for o in self[where][when]):
for other_function in self[where][when]:
if self._function_matches(other_function, function):
found = True
if not found:
self[where][when].append(function) self[where][when].append(function)
def clear(self): def clear(self):
for name, action_dict in self.items(): for name, action_dict in self.items():
for callback_list in action_dict.values(): for callback_list in action_dict.values():
while callback_list: callback_list[:] = []
callback_list.pop()
STEP_REGISTRY = {} STEP_REGISTRY = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment