MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / load_config

Function load_config

Utilities/JSON/ConfigValidate.py:26–37  ·  view source on GitHub ↗

Load a configuration file (JSON or YAML) based on its extension.

(file_path)

Source from the content-addressed store, hash-verified

24
25
26def load_config(file_path):
27 """Load a configuration file (JSON or YAML) based on its extension."""
28 suffix = pathlib.Path(file_path).suffix.lower()
29
30 try:
31 with open(file_path, 'r', encoding='utf-8') as f:
32 if suffix in ['.yaml', '.yml'] and YAML_SUPPORT:
33 return yaml.load(f, Loader=Loader)
34 else:
35 return json.load(f)
36 except Exception as e:
37 raise RuntimeError(f"Failed to load configuration file '{file_path}': {e}")
38
39
40def validate_config(schema_file, config_file, verbose=False):

Callers 1

validate_configFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected