Пример #1
0
    def test_it_should_load_from_file_and_directory(self, examples):
        examples.clear()
        paths = sorted(examples.get_many(SORTED_FILES))

        config = load_paths([paths[0], str(examples.tmpdir)])

        assert_that(config, has_entry('section', has_entry('key', 'second')))
Пример #2
0
    def test_it_should_filter_extensions(self, examples):
        examples.clear()
        examples.get_many(FILES)
        expected_contents = parse(examples.get(FILES[0]))  # toml file

        config = load_paths([str(examples.tmpdir)],
                            extension='toml',
                            force_extension=True)

        # Only reads the toml file
        assert_that(config, is_(expected_contents))
Пример #3
0
def get_config(overrides: ConfigDict) -> ConfigDict:
    """Read the config and merge with cli options"""
    overrides = {k: v for k, v in overrides.items() if v is not None}
    config_path = overrides.pop("config", None)
    try:
        if config_path:
            config = confight.load_paths([config_path])
        else:
            config = confight.load_user_app("rchat")
    except Exception as error:  # pylint: disable=broad-except
        raise click.ClickException(
            f"Could not load config ({config_path}): {error}"
        ) from error

    config = config.get("rchat") or {}
    config.update(**overrides)
    return config