Beispiel #1
0
def _all_tomls():
    file_paths = pathlib.Path(__file__).parent.glob("*.toml")
    toml = Configuration()
    for path in file_paths:
        print(path)
        toml.update_from_file(path)

    return toml
Beispiel #2
0
def read(cfg_name: str, *directories: pathlib.Path) -> Configuration:
    """Read one configuration from file

    Args:
        cfg_name:     Name of configuration, `.toml`-suffix is added
        directories:  Prioritized list of directories

    Returns:
        A configuration object
    """
    cfg = Configuration(cfg_name)
    for file_path in _config_paths(cfg_name,
                                   [pathlib.Path(d) for d in directories]):
        cfg.update_from_file(file_path)

    if not cfg:
        raise FileNotFoundError(
            f"Configuration {cfg_name!r} not found in {', '.join(directories)}"
        )

    return cfg