diff --git a/src/event_handlers/source_code_event_handler.py b/src/event_handlers/source_code_event_handler.py index eb64c1d..6dd33d7 100644 --- a/src/event_handlers/source_code_event_handler.py +++ b/src/event_handlers/source_code_event_handler.py @@ -59,15 +59,11 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin): def read(self, data): try: data['content'] = self.filemanager.file_contents except PermissionError: data['content'] = 'You have no permission to open that file :(' - data['filename'] = self.filemanager.filename - data['language'] = self.filemanager.language - data['files'] = self.filemanager.files return data def write(self, data): try: self.filemanager.file_contents = data['content'] except Exception: log.exception('Error writing file!') - data['files'] = self.filemanager.files self.restart_process() return data @@ -76,9 +72,15 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin): except EnvironmentError: log.exception('Failed to select file "{}"'.format(data['filename'])) return data + def attach_fileinfo(self, data): + data['filename'] = self.filemanager.filename + data['language'] = self.filemanager.language + data['files'] = self.filemanager.files + def handle_event(self, anchor, data_json): data = data_json['data'] data_json['data'] = self.commands[data['command']](data) + self.attach_fileinfo(data) return data_json