diff options
Diffstat (limited to 'gn3/fs_helpers.py')
-rw-r--r-- | gn3/fs_helpers.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/gn3/fs_helpers.py b/gn3/fs_helpers.py index 845c48b..c2c240c 100644 --- a/gn3/fs_helpers.py +++ b/gn3/fs_helpers.py @@ -13,19 +13,14 @@ from typing import List from typing import ValuesView from werkzeug.utils import secure_filename -def assert_path_exists(path: str, throw_error: bool = True) -> bool: - """Throw error if any of them do not exist.""" - if not os.path.isfile(path): - if throw_error: - raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path) - else: - return False - return True - -def assert_paths_exist(paths: ValuesView, throw_error: bool = True) -> bool: +def assert_paths_exist(paths: ValuesView) -> bool: """Given a list of PATHS, throw error if any of them do not exist.""" for path in paths: - assert_path_exists(path,throw_error) + if not os.path.isfile(path): + if throw_error: + raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path) + else: + return False return True def get_hash_of_files(files: List[str]) -> str: |