Add more heuristics for search_accdb
This commit is contained in:
@ -14,8 +14,7 @@ import pypyodbc
|
||||
import csv
|
||||
|
||||
|
||||
IGNORED_PATHS = ['C:\\Windows']
|
||||
IGNORED_NAMES = ['Program Files', 'Program Files (x86)', 'AppData']
|
||||
IGNORED_NAMES = ['Windows', 'Program Files', 'Program Files (x86)', 'AppData']
|
||||
|
||||
|
||||
def get_drives() -> List[str]:
|
||||
@ -31,14 +30,17 @@ def search_accdb(base_path: str = None) -> Generator[str, None, None]:
|
||||
for drive in get_drives():
|
||||
yield from search_accdb(f'{drive}:')
|
||||
return
|
||||
elif base_path.count('\\') >= 8:
|
||||
return
|
||||
try:
|
||||
for entry in os.scandir(f'{base_path}\\'):
|
||||
entries = [e for e in os.scandir(f'{base_path}\\')]
|
||||
for entry in entries:
|
||||
path = f'{base_path}\\{entry.name}'
|
||||
if path in IGNORED_PATHS or entry.name in IGNORED_NAMES:
|
||||
if entry.name in IGNORED_NAMES:
|
||||
continue
|
||||
if entry.is_file() and entry.name.lower().endswith('.accdb'):
|
||||
elif entry.is_file() and entry.name.lower().endswith('.accdb'):
|
||||
yield path
|
||||
elif entry.is_dir() and not entry.is_symlink():
|
||||
elif len(entries) <= 50 and entry.is_dir() and not entry.is_symlink():
|
||||
yield from search_accdb(path)
|
||||
except PermissionError:
|
||||
pass
|
||||
|
Reference in New Issue
Block a user