Load paths in order. Each path takes precedence over the previous path. Paths that don't exist are ignored, errors raise an OptionsError.
(opts: OptManager, *paths: Path | str)
| 562 | |
| 563 | |
| 564 | def load_paths(opts: OptManager, *paths: Path | str) -> None: |
| 565 | """ |
| 566 | Load paths in order. Each path takes precedence over the previous |
| 567 | path. Paths that don't exist are ignored, errors raise an |
| 568 | OptionsError. |
| 569 | """ |
| 570 | for p in paths: |
| 571 | p = Path(p).expanduser() |
| 572 | if p.exists() and p.is_file(): |
| 573 | with p.open(encoding="utf8") as f: |
| 574 | try: |
| 575 | txt = f.read() |
| 576 | except UnicodeDecodeError as e: |
| 577 | raise exceptions.OptionsError(f"Error reading {p}: {e}") |
| 578 | try: |
| 579 | load(opts, txt, cwd=p.absolute().parent) |
| 580 | except exceptions.OptionsError as e: |
| 581 | raise exceptions.OptionsError(f"Error reading {p}: {e}") |
| 582 | |
| 583 | |
| 584 | def serialize( |