From b643cd1edd1c168d92aba0016b7a46498f820ac0 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 22 Jun 2021 13:48:59 -0400 Subject: [PATCH] agent: Reimplement get_all_regular_files_in_directory using filter_files --- monkey/infection_monkey/utils/dir_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/utils/dir_utils.py b/monkey/infection_monkey/utils/dir_utils.py index 8b026d36d..3cc839d0e 100644 --- a/monkey/infection_monkey/utils/dir_utils.py +++ b/monkey/infection_monkey/utils/dir_utils.py @@ -1,12 +1,12 @@ 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]: - 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 for file_filter in file_filters: filtered_files = [f for f in filtered_files if file_filter(f)]