Load the config yaml as the base context, and enrich it with the information added by the context preprocessors defined in the file.
(config_fname: pathlib.Path, **kwargs)
| 385 | |
| 386 | |
| 387 | def get_context(config_fname: pathlib.Path, **kwargs): |
| 388 | """ |
| 389 | Load the config yaml as the base context, and enrich it with the |
| 390 | information added by the context preprocessors defined in the file. |
| 391 | """ |
| 392 | with config_fname.open(encoding="utf-8") as f: |
| 393 | context = yaml.safe_load(f) |
| 394 | |
| 395 | context["source_path"] = config_fname.parent |
| 396 | context.update(kwargs) |
| 397 | |
| 398 | preprocessors = ( |
| 399 | get_callable(context_prep) |
| 400 | for context_prep in context["main"]["context_preprocessors"] |
| 401 | ) |
| 402 | for preprocessor in preprocessors: |
| 403 | context = preprocessor(context) |
| 404 | msg = f"{preprocessor.__name__} is missing the return statement" |
| 405 | assert context is not None, msg |
| 406 | |
| 407 | return context |
| 408 | |
| 409 | |
| 410 | def get_source_files(source_path: pathlib.Path) -> typing.Generator[str, None, None]: |
no test coverage detected