Refactor file manager

This commit is contained in:
R. Richard 2019-05-20 14:50:02 +02:00
parent f495ff2d7c
commit a69031015b

View File

@ -16,7 +16,7 @@ LOG = logging.getLogger(__name__)
class FileManager: # pylint: disable=too-many-instance-attributes class FileManager: # pylint: disable=too-many-instance-attributes
def __init__(self, working_directory, allowed_directories, selected_file=None, exclude=None): def __init__(self, working_directory, allowed_directories, selected_file=None, exclude=None):
self._exclude, self.exclude = None, exclude self._exclude, self.exclude = [], exclude
self._allowed_directories, self.allowed_directories = None, allowed_directories self._allowed_directories, self.allowed_directories = None, allowed_directories
self._workdir, self.workdir = None, working_directory self._workdir, self.workdir = None, working_directory
self._filename, self.filename = None, selected_file or self.files[0] self._filename, self.filename = None, selected_file or self.files[0]
@ -91,7 +91,8 @@ class FileManager: # pylint: disable=too-many-instance-attributes
def _is_blacklisted(self, file): def _is_blacklisted(self, file):
return any( return any(
fnmatchcase(file, blacklisted) fnmatchcase(file, blacklisted) or
fnmatchcase(basename(file), blacklisted)
for blacklisted in self.exclude for blacklisted in self.exclude
) )