Make excluded stuff in FileManager configurable from __init__()

This commit is contained in:
Kristóf Tóth 2018-03-09 08:41:12 +01:00
parent b224ed519d
commit 7858caf51a
2 changed files with 5 additions and 5 deletions

View File

@ -9,8 +9,8 @@ log = logging.getLogger(__name__)
class FileManager: class FileManager:
def __init__(self, working_directory, selected_file=None): def __init__(self, working_directory, selected_file=None, exclude=None):
self.exclude = ['__pycache__'] self.exclude = exclude if exclude is not None else []
self._workdir = None self._workdir = None
self.workdir = working_directory self.workdir = working_directory
self.filename = selected_file or self.files[0] self.filename = selected_file or self.files[0]
@ -54,9 +54,9 @@ class FileManager:
class SourceCodeEventHandler(TriggerlessEventHandler): class SourceCodeEventHandler(TriggerlessEventHandler):
def __init__(self, key, directory, selected_file=None): def __init__(self, key, directory, selected_file=None, exclude=None):
super().__init__(key) super().__init__(key)
self.filemanager = FileManager(directory, selected_file=selected_file) self.filemanager = FileManager(directory, selected_file=selected_file, exclude=exclude)
self.commands = { self.commands = {
'read': self.read, 'read': self.read,

View File

@ -9,7 +9,7 @@ log = logging.getLogger(__name__)
if __name__ == '__main__': if __name__ == '__main__':
ide = SourceCodeEventHandler('webide', tfwenv.WEBIDE_WD) ide = SourceCodeEventHandler('webide', tfwenv.WEBIDE_WD, ['__pycache__'])
terminado = TerminadoEventHandler('shell') terminado = TerminadoEventHandler('shell')
terminado.historymonitor.subscribe_callback(lambda hist: log.debug('User executed command: "{}"'.format(hist[-1]))) terminado.historymonitor.subscribe_callback(lambda hist: log.debug('User executed command: "{}"'.format(hist[-1])))
processmanager = ProcessManagingEventHandler('processmanager', ide.monitor) processmanager = ProcessManagingEventHandler('processmanager', ide.monitor)