Refactor IdeEventHandler

This commit is contained in:
R. Richard 2019-06-27 14:48:27 +02:00 committed by Kristóf Tóth
parent 28f09086a2
commit 5f5fc1a8c9

View File

@ -10,7 +10,7 @@ from tfw.components.inotify import InotifyObserver
LOG = logging.getLogger(__name__)
BUILD_ARTIFACTS = [
BUILD_ARTIFACTS = (
"*.a",
"*.class",
"*.dll",
@ -31,7 +31,7 @@ BUILD_ARTIFACTS = [
"*.tar.gz",
"*.zip",
"*__pycache__*"
]
)
class IdeEventHandler(FrontendEventHandlerBase):
@ -71,13 +71,7 @@ class IdeEventHandler(FrontendEventHandlerBase):
)
self.monitor = InotifyObserver(self.filemanager.allowed_directories, exclude=BUILD_ARTIFACTS)
def on_modified(event):
LOG.debug(event)
self.server_connector.send_message({
'key': 'ide',
'data': {'command': 'reload'}
}, Scope.WEBSOCKET)
self.monitor.on_modified = on_modified
self.monitor.on_modified = self._reload_frontend
self.monitor.start()
self.commands = {
@ -88,6 +82,12 @@ class IdeEventHandler(FrontendEventHandlerBase):
'exclude': self.exclude
}
def _reload_frontend(self, event):
self.server_connector.send_message({
'key': 'ide',
'data': {'command': 'reload'}
}, Scope.WEBSOCKET)
def read(self, data):
"""
Read the currently selected file.