From ce07c4d6eccc456778c292e77e785e9da3132fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Bokros?= Date: Thu, 18 Jan 2018 14:35:53 +0100 Subject: [PATCH] Move commands to class variable --- src/event_handlers/source_code_event_handler.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/event_handlers/source_code_event_handler.py b/src/event_handlers/source_code_event_handler.py index c1192d6..5096793 100644 --- a/src/event_handlers/source_code_event_handler.py +++ b/src/event_handlers/source_code_event_handler.py @@ -14,6 +14,10 @@ class SourceCodeEventHandler(EventHandlerBase): self.filename = filename self.language = map_file_extension_to_language(filename) self.process_name = process_name or splitext(filename)[0] + self.commands = { + 'read': self.read_file, + 'write': self.write_file + } server = xmlrpc.client.ServerProxy(SUPERVISOR_HTTP_URI) self.supervisor = server.supervisor @@ -22,9 +26,7 @@ class SourceCodeEventHandler(EventHandlerBase): def handle_event(self, anchor, data_json): data = data_json['data'] - command_handlers = {'read': self.read_file, - 'write': self.write_file} - command_handlers[data['command']](data_json) + self.commands[data['command']](data_json) return data_json def handle_reset(self, data_json):