From 96f2d9f49613b9f79be355d271b6d5d19b569de2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 24 Dec 2017 20:41:38 +0100 Subject: [PATCH] Removed old processor module --- platypush/event/processor.py | 43 ------------------------------------ 1 file changed, 43 deletions(-) delete mode 100644 platypush/event/processor.py diff --git a/platypush/event/processor.py b/platypush/event/processor.py deleted file mode 100644 index 32689835c..000000000 --- a/platypush/event/processor.py +++ /dev/null @@ -1,43 +0,0 @@ -import logging - -from .rule import EventRule - -from platypush.config import Config -from platypush.message import Message -from platypush.message.request import Request - -class EventProcessor(object): - """ Event processor class. Checks an event against the configured - rules and executes any matching event hooks """ - - def __init__(self, hooks=Config.get_event_hooks(), **kwargs): - """ - Params: - hooks -- List of event hooks (default: any entry in the config - named as event.hook. """ - - self.hooks = {} - for (name, hook) in hooks.items(): - self.hooks[name] = { - 'if': EventRule.build(hook['if'] if 'if' in hook else {}), - 'then': hook['then'], - } - - def process_event(self, event): - """ Processes an event and runs any matched hooks """ - - matching_hooks = { name: hook['then'] for (name, hook) in self.hooks.items() - if event.matches_rule(hook['if']) } - - for (name, hook) in matching_hooks.items(): - logging.info('Running command {} triggered by matching event' - .format(name)) - - # TODO Extend the request with the parameters coming from the event. - # A hook should support a syntax like "playlist_id: $EVENT[playlist_id]" - request = Request.build(hook) - request.execute() - - -# vim:sw=4:ts=4:et: -