agent: Reimplement get_all_regular_files_in_directory using filter_files

This commit is contained in:
Mike Salvatore 2021-06-22 13:48:59 -04:00
parent f33772060f
commit b643cd1edd
1 changed files with 3 additions and 3 deletions

View File

@ -1,12 +1,12 @@
from pathlib import Path from pathlib import Path
from typing import Callable, List, Set from typing import Callable, Iterable, List, Set
def get_all_regular_files_in_directory(dir_path: Path) -> List[Path]: def get_all_regular_files_in_directory(dir_path: Path) -> List[Path]:
return [f for f in dir_path.iterdir() if f.is_file()] return filter_files(dir_path.iterdir(), [lambda f: f.is_file()])
def filter_files(files: List[Path], file_filters: List[Callable[[Path], bool]]): def filter_files(files: Iterable[Path], file_filters: List[Callable[[Path], bool]]):
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)]