aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorPjotr Prins2024-04-01 07:24:46 -0500
committerFrederick Muriuki Muriithi2024-09-12 07:40:02 -0500
commita9e73d2aa87d45e65cbaf9598ddcff278ba80ae5 (patch)
tree1ca21b73076c009c50896def40559f68c36a35e4 /gn3
parentdd888f89e60a986e030ad3d6ebdf081f986e4201 (diff)
downloadgenenetwork3-a9e73d2aa87d45e65cbaf9598ddcff278ba80ae5.tar.gz
Getting Rqtl to run on fallback
Diffstat (limited to 'gn3')
-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: