forked from p15670423/monkey
Agent: Add missing type hints to dir_utils.py
This commit is contained in:
parent
62efeffe90
commit
ce4c0188c2
|
@ -6,7 +6,9 @@ def get_all_regular_files_in_directory(dir_path: Path) -> List[Path]:
|
||||||
return filter_files(dir_path.iterdir(), [lambda f: f.is_file()])
|
return filter_files(dir_path.iterdir(), [lambda f: f.is_file()])
|
||||||
|
|
||||||
|
|
||||||
def filter_files(files: Iterable[Path], file_filters: List[Callable[[Path], bool]]):
|
def filter_files(
|
||||||
|
files: Iterable[Path], file_filters: Iterable[Callable[[Path], bool]]
|
||||||
|
) -> List[Path]:
|
||||||
filtered_files = files
|
filtered_files = files
|
||||||
for file_filter in file_filters:
|
for file_filter in file_filters:
|
||||||
filtered_files = [f for f in filtered_files if file_filter(f)]
|
filtered_files = [f for f in filtered_files if file_filter(f)]
|
||||||
|
@ -14,16 +16,16 @@ def filter_files(files: Iterable[Path], file_filters: List[Callable[[Path], bool
|
||||||
return filtered_files
|
return filtered_files
|
||||||
|
|
||||||
|
|
||||||
def file_extension_filter(file_extensions: Set):
|
def file_extension_filter(file_extensions: Set) -> Callable[[Path], bool]:
|
||||||
def inner_filter(f: Path):
|
def inner_filter(f: Path) -> bool:
|
||||||
return f.suffix in file_extensions
|
return f.suffix in file_extensions
|
||||||
|
|
||||||
return inner_filter
|
return inner_filter
|
||||||
|
|
||||||
|
|
||||||
def is_not_symlink_filter(f: Path):
|
def is_not_symlink_filter(f: Path) -> bool:
|
||||||
return not f.is_symlink()
|
return not f.is_symlink()
|
||||||
|
|
||||||
|
|
||||||
def is_not_shortcut_filter(f: Path):
|
def is_not_shortcut_filter(f: Path) -> bool:
|
||||||
return f.suffix != ".lnk"
|
return f.suffix != ".lnk"
|
||||||
|
|
Loading…
Reference in New Issue