diff options
| author | 2019-05-10 16:11:22 +0100 | |
|---|---|---|
| committer | 2019-05-10 16:11:22 +0100 | |
| commit | 091818fa32a67e973bdcda65a3edfe89a5a8c012 (patch) | |
| tree | 90bb7f9ca7a6e6a0fd676b9c4333c6750289e948 /src/EventManager.py | |
| parent | ignore users ignored from !factoid for automatic factoid parsing (diff) | |
| signature | ||
Hold context in EventCallback objects, add name<->context translation in
ModuleManager
Diffstat (limited to 'src/EventManager.py')
| -rw-r--r-- | src/EventManager.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/EventManager.py b/src/EventManager.py index 12ec524c..eae8a121 100644 --- a/src/EventManager.py +++ b/src/EventManager.py @@ -29,11 +29,12 @@ class Event(object): class EventCallback(object): def __init__(self, function: CALLBACK_TYPE, priority: int, kwargs: dict, - one_shot: bool=False): + context: typing.Optional[str], one_shot: bool=False): self.function = function self.priority = priority self.kwargs = kwargs self.docstring = utils.parse.docstring(function.__doc__ or "") + self.context = context self._one_shot = one_shot def call(self, event: Event) -> typing.Any: @@ -83,7 +84,7 @@ class EventHook(object): return self._hook(function, context, priority, replay, kwargs) def _hook(self, function: CALLBACK_TYPE, context: typing.Optional[str], priority: int, replay: bool, kwargs: dict) -> EventCallback: - callback = EventCallback(function, priority, kwargs) + callback = EventCallback(function, priority, kwargs, context) if context == None: self._hooks.append(callback) |
