foundry_dev_tools.utils.config module#
Utils functions for the configuration.
The config directories/files.
The environment config.
Function to merge dictionaries.
And the function that checks if the kwargs for a __init__ are correct,
currently used for the foundry_dev_tools.config.config.Config
and the token providers foundry_dev_tools.config.token_provider
.
- foundry_dev_tools.utils.config.cfg_files(use_project_config=True)[source]#
Returns all the possible configuration file paths (cached).
Returns a dict with the paths as keys. Sets are not ordered in python but dicts are since 3.8.
The first one is the system-wide config.
- foundry_dev_tools.utils.config.user_cfg_files()[source]#
Returns all possible user configuration files.
Returns a dict with the paths as keys. Sets are not ordered in python but dicts are since 3.8.
- foundry_dev_tools.utils.config.site_cfg_file()[source]#
Returns the site_config_path from
platformdirs
.- Return type:
- foundry_dev_tools.utils.config.user_cache()[source]#
Returns the cached directory for the user (cached).
- Return type:
- foundry_dev_tools.utils.config.path_from_path_or_str(path)[source]#
Returns the same variable if instance of Path otherwise create a Path.
- foundry_dev_tools.utils.config.find_project_config_file(project_directory=None, use_git=False, check_caller_file=True)[source]#
Get the project config file in a git repo.
- Parameters:
- Returns:
Path to the project config or None if no file was found
- Return type:
Path | None
- foundry_dev_tools.utils.config.get_environment_variable_config()[source]#
Returns the FDT_* environment variables as a config dict.
- Return type:
- foundry_dev_tools.utils.config.entry_point_fdt_token_provider()[source]#
Returns the token provider implementations registered via entry points.
- Return type:
dict[str, type[TokenProvider]]
- foundry_dev_tools.utils.config.entry_point_fdt_api_client()[source]#
Returns the API clients registered via entry points.
- foundry_dev_tools.utils.config.check_init(init_class, config_path, kwargs)[source]#
Checks if the supplied kwargs from the config dict are valid for the class to be instantiated.
If a kwargs is of the wrong type it will try to be cast to the correct type. If this fails a
FoundryConfigError
will be raised. If it succeeds it will still show a warning, that the value has been cast.- Parameters:
- Returns:
dict the kwargs that (were cast to) work for the instantiated class
- Return type:
valid_kwargs