nicetoolbox.utils.config

Functions for handling configuration files.

Functions

config_fill_auto

This function fills placeholders in the configuration data with auto-generated values.

config_fill_placeholders

Replace placeholders in the given configuration data with their corresponding values.

default

save_config

Save the given configuration data to the specified file.

nicetoolbox.utils.config.config_fill_auto(config, working_directory=None)[source]

This function fills placeholders in the configuration data with auto-generated values.

Parameters:
  • config (dict) – The configuration data to be processed.

  • working_directory (str, optional) – The directory where the git repository

  • located. (is) – Defaults to the current working directory.

Returns:

The configuration data with placeholders replaced with auto-generated values.

Return type:

dict

Note

This function uses the oslab_utils.git_utils module to get the git hash and commit message. The placeholders filled are: <git_hash>, <commit_message>, <me>, <yyyymmdd>, <today>, and <time>.

nicetoolbox.utils.config.config_fill_placeholders(config, placeholders)[source]

Replace placeholders in the given configuration data with their corresponding values.

Parameters:
  • config (dict or list) – The configuration data to be processed.

  • placeholders (dict) – A dictionary containing the placeholder values.

Returns:

The configuration data with placeholders replaced.

Return type:

dict

nicetoolbox.utils.config.save_config(configs: dict, config_file: str) None[source]

Save the given configuration data to the specified file.

Parameters:
  • configs (dict) – The configuration data to be saved.

  • config_file (str) – The path to the file where the configuration data

  • saved. (will be) –

Raises:

NotImplementedError – If the file type is not supported. Supported types are yaml/yml and toml.

Note

If the file type is Windows, it will convert the paths to Windows format.