mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-23 00:31:56 +00:00
Refactor blacklisting into a method in webide
This commit is contained in:
parent
4a216d8875
commit
8bd6005b5d
@ -65,9 +65,7 @@ class FileManager: # pylint: disable=too-many-instance-attributes
|
||||
@property
|
||||
def files(self):
|
||||
return [self._relpath(file) for file in glob(join(self._workdir, '**/*'), recursive=True)
|
||||
if isfile(file)
|
||||
and self._is_whitelisted(file)
|
||||
and not any(fnmatchcase(file, blacklisted) for blacklisted in self.exclude)]
|
||||
if isfile(file) and self._is_whitelisted(file) and not self._is_blacklisted(file)]
|
||||
|
||||
@property
|
||||
def file_contents(self):
|
||||
@ -82,6 +80,9 @@ class FileManager: # pylint: disable=too-many-instance-attributes
|
||||
def _is_whitelisted(self, file):
|
||||
return any(realpath(file).startswith(allowed_dir) for allowed_dir in self.allowed_directories)
|
||||
|
||||
def _is_blacklisted(self, file):
|
||||
return any(fnmatchcase(file, blacklisted) for blacklisted in self.exclude)
|
||||
|
||||
def _filepath(self, filename):
|
||||
return join(self._workdir, filename)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user