reformat
This commit is contained in:
32
callbacks.py
32
callbacks.py
@@ -82,16 +82,36 @@ class Callbacks:
|
||||
for app_name, app_callbacks in self.callbacks.items()
|
||||
}
|
||||
|
||||
async def get_callback_handles(self, app: str = 'all', type: str = 'all', entity_id: str = 'all'):
|
||||
async def get_callbacks(
|
||||
self,
|
||||
namespace: str = 'all',
|
||||
app: str = 'all',
|
||||
type: str = 'all',
|
||||
entity_id: str = 'all',
|
||||
copy: bool = True,
|
||||
) -> dict[str, dict[str, Any]]:
|
||||
async with self.callbacks_lock:
|
||||
handles = set(
|
||||
handle
|
||||
return {
|
||||
handle: deepcopy(cb_info) if copy else cb_info
|
||||
for app_name, app_callbacks in self.callbacks.items()
|
||||
if app == 'all' or app == app_name
|
||||
for handle, cb_info in app_callbacks.items()
|
||||
if (type == 'all' or type == cb_info["type"])
|
||||
and (entity_id == 'all' or entity_id == cb_info["entity"])
|
||||
)
|
||||
self.logger.debug(f"Got {len(handles)} callbacks for app={app}, type={type}, entity_id={entity_id}")
|
||||
return handles
|
||||
and (
|
||||
namespace == 'all'
|
||||
or namespace == 'global'
|
||||
or cb_info["namespace"] == 'global'
|
||||
or namespace == cb_info["namespace"]
|
||||
)
|
||||
}
|
||||
|
||||
async def get_callback_handles(
|
||||
self,
|
||||
namespace: str = 'all',
|
||||
app: str = 'all',
|
||||
type: str = 'all',
|
||||
entity_id: str = 'all'
|
||||
) -> set[str]:
|
||||
callbacks = await self.get_callbacks(namespace, app, type, entity_id, copy=False)
|
||||
return set(callbacks.keys())
|
||||
|
||||
Reference in New Issue
Block a user