From 76ccc4dbaeaedf0275587bd319d63fdc58d00ac8 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Tue, 17 Dec 2024 10:48:33 +0100 Subject: [PATCH] Update tools/schemacode/src/bidsschematools/types/namespace.py Co-authored-by: Chris Markiewicz --- .../src/bidsschematools/types/namespace.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/schemacode/src/bidsschematools/types/namespace.py b/tools/schemacode/src/bidsschematools/types/namespace.py index 73b06ed060..52f21e2d0c 100644 --- a/tools/schemacode/src/bidsschematools/types/namespace.py +++ b/tools/schemacode/src/bidsschematools/types/namespace.py @@ -272,13 +272,13 @@ def from_json(cls, jsonstr: str): def _read_yaml_dir(path: Path) -> dict: mapping = {} for subpath in sorted(path.iterdir()): - try: - if subpath.is_dir(): - mapping[subpath.name] = _read_yaml_dir(subpath) - elif subpath.name.endswith("yaml"): + if subpath.is_dir(): + mapping[subpath.name] = _read_yaml_dir(subpath) + elif subpath.name.endswith("yaml"): + try: mapping[subpath.stem] = yaml.safe_load(subpath.read_text()) - except Exception as e: - raise ValueError(f"There was an error reading the file: {subpath}") from e + except Exception as e: + raise ValueError(f"There was an error reading the file: {subpath}") from e return mapping