chicken_turtle_util.configuration

Configuration loaders, currently only from configuration files

ConfigurationLoader Loads a single configuration from one or more files
class chicken_turtle_util.configuration.ConfigurationLoader(package_name, directory_name, configuration_name)[source]

Loads a single configuration from one or more files

Reads configuration files in this order:

  1. /etc/{directory_name}/{configuration_name}.conf
  2. for each XDG config dir, try {xdg_config_dir}/{directory_name}/{configuration_name}.conf

If none are found, the defaults are used. The first configuration file can be said to inherit the defaults. Any next configuration files inherit the configuration of their predecessors. Defaults are specified in the package data of package_name with path data/{configuration_name}.defaults.conf.

Configuration values are treated as strings. Empty strings are allowed. Inline comments can be started with ‘#’ and ‘;’. The ‘default’ section provides defaults for other sections. ExtendedInterpolation is used. Option names have ‘-‘ and ‘ ‘ replaced with ‘_’; section names do not, but as that may change in the future, we recommend using all underscore section names only.

Parameters:

package_name : str

Fully qualified name of the package whose package data contains the defaults file

directory_name : str

Name of directory in which configuration files should reside.

configuration_name : str

Name of configuration file (without suffix; a ‘.conf’ suffix is added)

Notes

The interface also aims to enforce consistency and good practice across applications, so it’s kept intentionally rigid in some regards.