about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gn3/fs_helpers.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/gn3/fs_helpers.py b/gn3/fs_helpers.py
index 74e7ada..845c48b 100644
--- a/gn3/fs_helpers.py
+++ b/gn3/fs_helpers.py
@@ -13,14 +13,19 @@ 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:
     """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
+        assert_path_exists(path,throw_error)
     return True
 
 def get_hash_of_files(files: List[str]) -> str: