From 8c492df646e1435a4d7932b213b3cbc54d369dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Thu, 8 Feb 2018 16:56:30 +0100 Subject: [PATCH] Implement exclude list in FileManager --- src/event_handlers/source_code_event_handler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/event_handlers/source_code_event_handler.py b/src/event_handlers/source_code_event_handler.py index 8109504..b92cc80 100644 --- a/src/event_handlers/source_code_event_handler.py +++ b/src/event_handlers/source_code_event_handler.py @@ -10,6 +10,7 @@ log = logging.getLogger(__name__) class FileManager: def __init__(self, working_directory, selected_file=None): + self.exclude = ['__pycache__'] self._workdir = working_directory self.filename = selected_file or self._relpath(self.files[0]) self.language = map_file_extension_to_language(self.filename) @@ -22,7 +23,9 @@ class FileManager: @property def files(self): - return [self._relpath(file) for file in glob(join(self._workdir, '**/*'), recursive=True) if isfile(file)] + return [self._relpath(file) for file in glob(join(self._workdir, '**/*'), recursive=True) + if isfile(file) and + not any(word in file for word in self.exclude)] @property def file_contents(self):