in transcoder/Transcoder.py [0:0]
def setup_handlers(self):
"""Initialize MessageHandler instances to employ at runtime"""
if self.message_handler_spec is None or self.message_handler_spec == "":
return
self.handlers_enabled = True
handler_strs = self.message_handler_spec.split(',')
for handler_spec in handler_strs:
cls_name = None
config_dict = None
if handler_spec.find(':') == -1: # no handler params
cls_name = handler_spec
else:
cls_name = handler_spec.split(':')[0]
config_dict = parse_handler_config(handler_spec)
module = importlib.import_module('transcoder.message.handler')
class_ = getattr(module, cls_name)
instance = class_(config_dict)
self.all_handlers.append(instance)
if instance.supports_all_message_types is True:
self.all_message_type_handlers.append(instance)
continue
supported_msg_types = instance.supported_message_types
for supported_type in supported_msg_types:
if supported_type in self.message_handlers:
handler_list = self.message_handlers[supported_type]
if instance not in handler_list:
self.message_handlers[supported_type].append(instance)
else:
self.message_handlers[supported_type] = [instance]