Skip to content

Commit

Permalink
Merge pull request #206 from Olmichu22/except_hand
Browse files Browse the repository at this point in the history
Added Exceptions to Handle Non-Existent Directories
  • Loading branch information
TjarkMiener authored Sep 16, 2024
2 parents 70ad225 + c83b67a commit 88a1ba8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ctlearn/build_irf.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ def main():
n_showers_factor = 1
for input in args.input:
abs_file_dir = os.path.abspath(input)
# Exception handling for the input directory
if not os.path.isdir(abs_file_dir):
raise NotADirectoryError(f"'{abs_file_dir}' is not a directory.")
for pattern in args.pattern:
files = glob.glob(os.path.join(abs_file_dir, pattern))
if not files:
Expand Down
6 changes: 6 additions & 0 deletions ctlearn/run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ def main():
if args.input:
for input in args.input:
abs_file_dir = os.path.abspath(input)
# Exception handling for the input directory
if not os.path.isdir(abs_file_dir):
raise NotADirectoryError(f"'{abs_file_dir}' is not a directory.")
with open(training_file_list, "a") as file_list:
for pattern in args.pattern:
files = glob.glob(os.path.join(abs_file_dir, pattern))
Expand Down Expand Up @@ -683,6 +686,9 @@ def main():
if args.input:
for input in args.input:
abs_file_dir = os.path.abspath(input)
# Exception handling for the input directory
if not os.path.isdir(abs_file_dir):
raise NotADirectoryError(f"'{abs_file_dir}' is not a directory.")
for pattern in args.pattern:
files = glob.glob(os.path.join(abs_file_dir, pattern))
if not files:
Expand Down

0 comments on commit 88a1ba8

Please sign in to comment.