Skip to content

Commit

Permalink
Fix _bids_filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Jan 25, 2024
1 parent a35e82b commit 9581a69
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions aslprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ def _filter_pybids_none_any(dct):
d[k] = _process_value(v)
return d

def _bids_filter(value):
from json import loads

if value and Path(value).exists():
return loads(Path(value).read_text(), object_hook=_filter_pybids_none_any)
def _bids_filter(value, parser):
from json import JSONDecodeError, loads

if value:
if Path(value).exists():
try:
return loads(Path(value).read_text(), object_hook=_filter_pybids_none_any)
except JSONDecodeError:
raise parser.error(f"JSON syntax error in: <{value}>.")
else:
raise parser.error(f"Path does not exist: <{value}>.")

verstr = f"ASLPrep v{config.environment.version}"
currentv = Version(config.environment.version)
Expand Down

0 comments on commit 9581a69

Please sign in to comment.