diff options
Diffstat (limited to 'gn3/fs_helpers.py')
-rw-r--r-- | gn3/fs_helpers.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gn3/fs_helpers.py b/gn3/fs_helpers.py index e7366ac..6b0a00a 100644 --- a/gn3/fs_helpers.py +++ b/gn3/fs_helpers.py @@ -11,6 +11,15 @@ from typing import Dict from typing import List from werkzeug.utils import secure_filename +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: + 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: """Given a list of valid of FILES, return their hash as a string""" |