remove_handlers_by_module moved into Houdini.Handlers module

This commit is contained in:
Ben 2019-04-11 01:02:30 +01:00
parent 5a01be8c68
commit 30f1f1fb7f
2 changed files with 12 additions and 18 deletions

View File

@ -36,19 +36,3 @@ def evaluate_plugin_file_event(plugin_file_event):
return handler_module_path, ".".join(handler_module_tokens)
return False
def remove_handlers_by_module(xt_listeners, xml_listeners, handler_module_path):
def remove_handlers(remove_handler_items):
for handler_id, handler_listeners in remove_handler_items:
for handler_listener in handler_listeners:
if handler_listener.handler_file == handler_module_path:
handler_listeners.remove(handler_listener)
xt_handler_collection = copy.copy(xt_listeners)
remove_handlers(xt_listeners.items())
xml_handler_collection = copy.copy(xml_listeners)
remove_handlers(xml_listeners.items())
return xt_handler_collection, xml_handler_collection

View File

@ -241,9 +241,19 @@ def listeners_from_module(xt_listeners, xml_listeners, module):
listener_collection[override.packet].remove(override)
def cooldown(per=1.0, rate=1, bucket_type=BucketType.Default):
def remove_handlers_by_module(xt_listeners, xml_listeners, handler_module_path):
def remove_handlers(remove_handler_items):
for handler_id, handler_listeners in remove_handler_items:
for handler_listener in handler_listeners:
if handler_listener.handler_file == handler_module_path:
handler_listeners.remove(handler_listener)
remove_handlers(xt_listeners.items())
remove_handlers(xml_listeners.items())
def cooldown(per=1.0, rate=1, bucket_type=BucketType.Default, callback=None):
def decorator(handler_function):
handler_function.cooldown = _CooldownMapping(_Cooldown(per, rate, bucket_type))
handler_function.__cooldown = _CooldownMapping(callback, _Cooldown(per, rate, bucket_type))
return handler_function
return decorator