Reformatted code base using black.
This commit is contained in:
parent
56319cbad3
commit
53fdaa9d09
1 changed files with 12604 additions and 8966 deletions
|
|
@ -55,7 +55,9 @@ class PubsubHook(object):
|
|||
def __init__(self, host):
|
||||
log.info(_("PubSub Hook initialization"))
|
||||
self.host = host
|
||||
self.node_hooks = {} # keep track of the number of hooks per node (for all profiles)
|
||||
self.node_hooks = (
|
||||
{}
|
||||
) # keep track of the number of hooks per node (for all profiles)
|
||||
host.bridge.add_method(
|
||||
"ps_hook_add", ".plugin", in_sign="ssssbs", out_sign="", method=self._addHook
|
||||
)
|
||||
|
|
@ -108,7 +110,9 @@ class PubsubHook(object):
|
|||
else:
|
||||
if self.node_hooks[node] == 0:
|
||||
del self.node_hooks[node]
|
||||
self.host.plugins["XEP-0060"].remove_managed_node(node, self._items_received)
|
||||
self.host.plugins["XEP-0060"].remove_managed_node(
|
||||
node, self._items_received
|
||||
)
|
||||
log.debug(_("hook removed"))
|
||||
else:
|
||||
log.debug(_("node still needed for an other hook"))
|
||||
|
|
@ -120,9 +124,7 @@ class PubsubHook(object):
|
|||
)
|
||||
if hook_type != HOOK_TYPE_PYTHON_FILE:
|
||||
raise NotImplementedError(
|
||||
_("{hook_type} hook type not implemented yet").format(
|
||||
hook_type=hook_type
|
||||
)
|
||||
_("{hook_type} hook type not implemented yet").format(hook_type=hook_type)
|
||||
)
|
||||
self._install_node_manager(client, node)
|
||||
hook_data = {"service": service, "type": hook_type, "arg": hook_arg}
|
||||
|
|
@ -160,7 +162,14 @@ class PubsubHook(object):
|
|||
try:
|
||||
if hook_type == HOOK_TYPE_PYTHON_FILE:
|
||||
hook_globals = {}
|
||||
exec(compile(open(hook_data["arg"], "rb").read(), hook_data["arg"], 'exec'), hook_globals)
|
||||
exec(
|
||||
compile(
|
||||
open(hook_data["arg"], "rb").read(),
|
||||
hook_data["arg"],
|
||||
"exec",
|
||||
),
|
||||
hook_globals,
|
||||
)
|
||||
callback = hook_globals["hook"]
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
|
|
@ -224,7 +233,9 @@ class PubsubHook(object):
|
|||
def _removeHook(self, service, node, hook_type, hook_arg, profile):
|
||||
client = self.host.get_client(profile)
|
||||
service = jid.JID(service) if service else client.jid.userhostJID()
|
||||
return self.remove_hook(client, service, node, hook_type or None, hook_arg or None)
|
||||
return self.remove_hook(
|
||||
client, service, node, hook_type or None, hook_arg or None
|
||||
)
|
||||
|
||||
def remove_hook(self, client, service, node, hook_type=None, hook_arg=None):
|
||||
"""Remove a persistent or temporaty root
|
||||
|
|
|
|||
Loading…
Reference in a new issue