mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 22:21:56 +00:00
Allow passing an iterable with keys to subscribe to in EventHandlerBase.__init__()
This commit is contained in:
parent
90b780a5c0
commit
9ad77eaed8
@ -3,6 +3,7 @@
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from inspect import currentframe
|
||||
from typing import Iterable
|
||||
|
||||
from tfw.networking.event_handlers import ServerConnector
|
||||
from tfw.crypto import message_checksum, KeyManager, verify_message
|
||||
@ -20,7 +21,12 @@ class EventHandlerBase(ABC):
|
||||
"""
|
||||
def __init__(self, key):
|
||||
self.server_connector = ServerConnector()
|
||||
self.keys = [key]
|
||||
self.keys = []
|
||||
if isinstance(key, str):
|
||||
self.keys.append(key)
|
||||
elif isinstance(key, Iterable):
|
||||
self.keys = list(key)
|
||||
|
||||
self.subscribe(*self.keys)
|
||||
self.server_connector.register_callback(self.event_handler_callback)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user