Skip to content

Commit

Permalink
Merge pull request #315 from Deltares/yml_fix
Browse files Browse the repository at this point in the history
small fix parsing paths in yml
  • Loading branch information
DirkEilander authored Apr 13, 2023
2 parents 3949d7e + 13d207a commit 810872e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions hydromt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,18 @@ def parse_abspath(
"""

def _abspath(value, root):
if isinstance(value, str) and exists(join(root, value)):
if exists(join(root, value)):
value = Path(abspath(join(root, value)))
elif (
isinstance(value, list)
and all([isinstance(v, str) for v in value])
and all([exists(join(root, v)) for v in value])
):
value = [Path(abspath(join(root, v))) for v in value]
return value

# loop through n-level of dict
for key, val in cfdict.items():
if isinstance(val, dict):
if key not in skip_abspath_sections:
cfdict[key] = parse_abspath(val, root)
else:
elif isinstance(val, list) and all([isinstance(v, str) for v in val]):
cfdict[key] = [_abspath(v, root) for v in val]
elif isinstance(val, str):
cfdict[key] = _abspath(val, root)
return cfdict

Expand Down

0 comments on commit 810872e

Please sign in to comment.