mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 21:21:32 +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
|
@property
|
||||||
def files(self):
|
def files(self):
|
||||||
return [self._relpath(file) for file in glob(join(self._workdir, '**/*'), recursive=True)
|
return [self._relpath(file) for file in glob(join(self._workdir, '**/*'), recursive=True)
|
||||||
if isfile(file)
|
if isfile(file) and self._is_whitelisted(file) and not self._is_blacklisted(file)]
|
||||||
and self._is_whitelisted(file)
|
|
||||||
and not any(fnmatchcase(file, blacklisted) for blacklisted in self.exclude)]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def file_contents(self):
|
def file_contents(self):
|
||||||
@ -82,6 +80,9 @@ class FileManager: # pylint: disable=too-many-instance-attributes
|
|||||||
def _is_whitelisted(self, file):
|
def _is_whitelisted(self, file):
|
||||||
return any(realpath(file).startswith(allowed_dir) for allowed_dir in self.allowed_directories)
|
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):
|
def _filepath(self, filename):
|
||||||
return join(self._workdir, filename)
|
return join(self._workdir, filename)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user