experimentum.Config package

Submodules

experimentum.Config.Config module

The config module stores all config items.

The Config class supports the dot-notation which means that you can access nested elements seperated by a ., e.g. foo.bar.baz.

Example:

cfg = Config()
cfg.set({ 'foo': 'bar', 'foobar': {'baz': 42 } })
cfg.set('a.b', 'c')

cfg.get('foobar.baz')  # returns: 42
cfg.has('foobar.foo')  # returns: False
cfg.all()              # returns: { 'foo': 'bar', 'foobar': {'baz': 42 }, 'a': {'b': 'c'} }
class experimentum.Config.Config.Config

Bases: object

Manages all the config items.

items

Loaded config items.

Type:dict
all()

Get all of the configuration items for the application.

Returns:config items
Return type:dict
get(key, default=None)

Get the specified configuration value.

Parameters:
  • key (string|list) – Set of keys.
  • default (object, optional) – Defaults to None. A default value if the key is not found
Returns:

The config value.

Return type:

object

get_many(keys)

Get many configuration values.

Parameters:keys (list) – Names of the keys.
Returns:Donfig items for the set of keys.
Return type:dict
has(key)

Determine if the given configuration value exists.

Parameters:key (string) – config item key
Returns:bool
set(key, value=None)

Set a given configuration value.

Parameters:
  • key (dict|string) – Config item keys to change the value
  • value (object,optional) – Defaults to None. New value

experimentum.Config.Loader module

The Config Loader module loads json config files.

The Loader loads all json files from a folder and stores the content in the Config class.

class experimentum.Config.Loader.Loader(config_path, config)

Bases: object

Load the configuration files.

config_path

Path to config files.

Type:str
config

Config holder class

Type:Config
classmethod config_key(fname)

Get the config key based on the filename.

Parameters:fname (str) – Name of the config file.
Returns:key
Return type:str
get_config_files()

Get all of the configuration files for the application.

Returns:The config items.
Return type:dict
load_config_files()

Load the configuration items from all of the files.

Raises:Exception – if there is no app.json config.

Module contents

Provides Config Holder and Config Loader modules to easily load/store config items.

Import Loader and Config so that they can be easly imported by other packages/modules.