MCPcopy
hub / github.com/copier-org/copier / load_answersfile_data

Function load_answersfile_data

copier/_user_data.py:587–603  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

585
586
587def 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
606CAST_STR_TO_NATIVE: Mapping[str, Callable[[str], Any]] = {

Calls

no outgoing calls