read_config

Contents

read_config#

read_config(filename, verbose=False)[source]#

Read a single configuration file.

  • If the input filename does not specifically include a directory, it is looked for in the default PACKAGE_PATH.joinpath("config") directory.

  • Currently, only .toml configuration files are supported.

Parameters:
  • filename (str, list or dict) –

    Filename of the configuration file. If no extension is provided, .toml is assumed: filename="supernova" is equivalent to filename="supernova.toml". A dict is returned as is.

    filename can also be a list of names, dicts, or a mix of both. These nested dictionaries are merged from left to right, such that for filename = ["supernova", "zodi"], the configuration from "zodi" overwrites the corresponding (nested) entries from "supernova". A dict element is assumed to be a configuration. For example, ["supernova", {"scene": {"pointsource": {"source": [lbda_ref, flux_ref]}}}] overwrites the scene.pointsource.source entry of the "supernova" configuration.

  • verbose (bool, optional) – If True, print the name of the file being read (not propagated to the elements of a list). Default is False.

Returns:

dict – Configuration as a nested dictionary.

Raises:

NotImplementedError – If the configuration file extension is not supported.