mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Remove special casing of hidden files
If it is necessary to exclude hidden files, then adding ``` paths-ignore: ['**/.*/**'] ``` to the relevant config file is recommended instead.
This commit is contained in:
@@ -85,48 +85,19 @@ class Traverser(object):
|
||||
if isdir(fullpath):
|
||||
if fullpath in self.exclude_paths:
|
||||
self.logger.debug("Ignoring %s (excluded)", fullpath)
|
||||
elif is_hidden(fullpath):
|
||||
self.logger.debug("Ignoring %s (hidden)", fullpath)
|
||||
else:
|
||||
empty = True
|
||||
for item in self._treewalk(fullpath):
|
||||
yield item
|
||||
empty = False
|
||||
if not empty:
|
||||
yield fullpath
|
||||
continue
|
||||
|
||||
empty = True
|
||||
for item in self._treewalk(fullpath):
|
||||
yield item
|
||||
empty = False
|
||||
if not empty:
|
||||
yield fullpath
|
||||
elif self.filter(fullpath):
|
||||
yield fullpath
|
||||
else:
|
||||
self.logger.debug("Ignoring %s (filter)", fullpath)
|
||||
|
||||
|
||||
if os.environ.get("CODEQL_EXTRACTOR_PYTHON_OPTION_SKIP_HIDDEN_DIRECTORIES", "false") == "false":
|
||||
|
||||
def is_hidden(path):
|
||||
return False
|
||||
|
||||
elif os.name== 'nt':
|
||||
import ctypes
|
||||
|
||||
def is_hidden(path):
|
||||
#Magical windows code
|
||||
try:
|
||||
attrs = ctypes.windll.kernel32.GetFileAttributesW(str(path))
|
||||
if attrs == -1:
|
||||
return False
|
||||
if attrs&2:
|
||||
return True
|
||||
except Exception:
|
||||
#Not sure what to log here, probably best to carry on.
|
||||
pass
|
||||
return os.path.basename(path).startswith(".")
|
||||
|
||||
else:
|
||||
|
||||
def is_hidden(path):
|
||||
return os.path.basename(path).startswith(".")
|
||||
|
||||
|
||||
def exclude_filter_from_options(options):
|
||||
if options.exclude_package:
|
||||
choices = '|'.join(mod.replace('.', r'\.') for mod in options.exclude_package)
|
||||
|
||||
Reference in New Issue
Block a user