Load answers data from a `$dst_path/$answers_file` file if it exists.
(
dst_path: StrOrPath,
answers_file: StrOrPath = ".copier-answers.yml",
*,
warn_on_missing: bool = False,
)
| 585 | |
| 586 | |
| 587 | def load_answersfile_data( |
| 588 | dst_path: StrOrPath, |
| 589 | answers_file: StrOrPath = ".copier-answers.yml", |
| 590 | *, |
| 591 | warn_on_missing: bool = False, |
| 592 | ) -> AnyByStrDict: |
| 593 | """Load answers data from a `$dst_path/$answers_file` file if it exists.""" |
| 594 | try: |
| 595 | with Path(dst_path, answers_file).open("rb") as fd: |
| 596 | return yaml.safe_load(fd) |
| 597 | except (FileNotFoundError, IsADirectoryError): |
| 598 | if warn_on_missing: |
| 599 | warnings.warn( |
| 600 | f"File not found; returning empty dict: {answers_file}", |
| 601 | MissingFileWarning, |
| 602 | ) |
| 603 | return {} |
| 604 | |
| 605 | |
| 606 | CAST_STR_TO_NATIVE: Mapping[str, Callable[[str], Any]] = { |
no outgoing calls