openscm_runner.settings#
Settings handling
Rather than hard-coding constants, configuration can be source from 2 different sources:
Environment variables
dotenv files
Environment variables are always used in preference to the values in dotenv files.
ConfigLoader#
- class ConfigLoader[source]#
Bases:
object
Configuration container
Loads a local dotenv file containing configuration. An example of a configuration file is provided in root of the project.
A combination of environment variables and dotenv files can be used as configuration with an existing environment variables overriding a value specified in a dotenv file.
All configuration is case-insensitive.
>>> config = ConfigLoader() >>> config["VALUE"] Traceback (most recent call last): ... KeyError: 'VALUE' >>> config.get("VALUE", "some_default") 'some_default'
- get(key, default=None)[source]#
Get value for a given key, falling back to a default value if not present.
- Parameters:
key (str) – Key
default (Any) – Default value returned if no configuration for
key
is present.
- Returns:
Any – Value with key
item
. If not value is presentdefault
is returned.