<commit_before>from pathlib import Path

from .tools import printf, printf_block, prompt, STYLE_WARNING
from .types import AnyByStr, StrOrPath

__all__ = ("load_config_data", "query_user_data")

INDENT = "  "


def load_toml_data(src_path: StrOrPath, quiet: bool = False) -> AnyByStr:
    toml_path = Path(src_path) / "copier.toml"
    if not toml_path.exists():
        return {}

    import toml

    toml_src = toml_path.read_text()
    try:
        return dict(toml.loads(toml_src))
    except Exception as e:
        printf_block(e, "INVALID", msg=str(toml_path), quiet=quiet)
        return {}


def load_yaml_data(src_path: StrOrPath, quiet: bool = False) -> AnyByStr:
    yaml_path = Path(src_path) / "copier.yml"
    if not yaml_path.exists():<commit_msg>Ignoring missing toml import in user_data.<commit_after>from pathlib import Path

from .tools import printf, printf_block, prompt, STYLE_WARNING
from .types import AnyByStr, StrOrPath

__all__ = ("load_config_data", "query_user_data")

INDENT = "  "


def load_toml_data(src_path: StrOrPath, quiet: bool = False) -> AnyByStr:
    toml_path = Path(src_path) / "copier.toml"
    if not toml_path.exists():
        return {}

    import toml  # type: ignore

    toml_src = toml_path.read_text()
    try:
        return dict(toml.loads(toml_src))
    except Exception as e:
        printf_block(e, "INVALID", msg=str(toml_path), quiet=quiet)
        return {}


def load_yaml_data(src_path: StrOrPath, quiet: bool = False) -> AnyByStr:
    yaml_path = Path(src_path) / "copier.yml"
    if not yaml_path.exists():
{'fraction_non_alphanumeric': 0.11125238397965671, 'fraction_numerical': 0.0, 'mean_word_length': 3.6706231454005933, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1634917', 'n_tokens_mistral': 569, 'n_tokens_neox': 552, 'n_words': 132}