Skip to content

Commit

Permalink
Merge pull request #1086 from karanphil/update_assert_inputs_exist
Browse files Browse the repository at this point in the history
Adding support for list of lists of paths in assert_inputs_exist
  • Loading branch information
arnaudbore authored Jan 17, 2025
2 parents 2476ec2 + 2aeb19b commit 118ce1c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scilpy/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,9 +720,9 @@ def assert_inputs_exist(parser, required, optional=None):
----------
parser: argparse.ArgumentParser object
Parser.
required: string or list of paths
required: string or list of paths or list of lists of paths
Required paths to be checked.
optional: string or list of paths
optional: string or list of paths or list of lists of paths
Optional paths to be checked.
"""

Expand All @@ -737,10 +737,18 @@ def check(path):
optional = [optional]

for required_file in required:
check(required_file)
if isinstance(required_file, str):
check(required_file)
else:
for file in required_file:
check(file)
for optional_file in optional or []:
if optional_file is not None:
check(optional_file)
if isinstance(optional_file, str):
check(optional_file)
else:
for file in optional_file:
check(file)


def assert_inputs_dirs_exist(parser, required, optional=None):
Expand Down

0 comments on commit 118ce1c

Please sign in to comment.