Reformatted code base using black.
This commit is contained in:
parent
56319cbad3
commit
53fdaa9d09
1 changed files with 12604 additions and 8966 deletions
|
|
@ -33,7 +33,7 @@ class TriggerException(Exception):
|
|||
|
||||
|
||||
class SkipOtherTriggers(Exception):
|
||||
""" Exception to raise if normal behaviour must be followed instead of following triggers list """
|
||||
"""Exception to raise if normal behaviour must be followed instead of following triggers list"""
|
||||
|
||||
pass
|
||||
|
||||
|
|
@ -62,7 +62,6 @@ class TriggerManager(object):
|
|||
# plugins are always avaialble for normal clients
|
||||
return True
|
||||
|
||||
|
||||
def add(self, point_name, callback: Callable, priority=0):
|
||||
"""Add a trigger to a point
|
||||
|
||||
|
|
@ -89,11 +88,7 @@ class TriggerManager(object):
|
|||
)
|
||||
|
||||
def add_with_check(
|
||||
self,
|
||||
point_name: str,
|
||||
plugin,
|
||||
callback: Callable,
|
||||
priority: int=0
|
||||
self, point_name: str, plugin, callback: Callable, priority: int = 0
|
||||
) -> None:
|
||||
"""Like [Add], but check session before running the trigger
|
||||
|
||||
|
|
@ -109,20 +104,24 @@ class TriggerManager(object):
|
|||
@param priority: callback will be called in priority order, biggest first
|
||||
"""
|
||||
if inspect.iscoroutinefunction(callback):
|
||||
|
||||
async def async_wrapper(client: SatXMPPEntity, *args, **kwargs):
|
||||
if client.is_component and plugin not in client.plugins:
|
||||
log.debug(f"Ignoring {callback} as parent plugin is not available")
|
||||
return True
|
||||
else:
|
||||
return await callback(client, *args, **kwargs)
|
||||
|
||||
self.add(point_name, async_wrapper, priority)
|
||||
else:
|
||||
|
||||
def sync_wrapper(client: SatXMPPEntity, *args, **kwargs):
|
||||
if client.is_component and plugin not in client.plugins:
|
||||
log.debug(f"Ignoring {callback} as parent plugin is not available")
|
||||
return True
|
||||
else:
|
||||
return callback(client, *args, **kwargs)
|
||||
|
||||
self.add(point_name, sync_wrapper, priority)
|
||||
|
||||
def remove(self, point_name, callback):
|
||||
|
|
@ -152,7 +151,7 @@ class TriggerManager(object):
|
|||
if point_name not in self.__triggers:
|
||||
return True
|
||||
|
||||
can_cancel = not kwargs.pop('triggers_no_cancel', False)
|
||||
can_cancel = not kwargs.pop("triggers_no_cancel", False)
|
||||
|
||||
for priority, trigger in self.__triggers[point_name]:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue