peltak.core.conf

class peltak.core.conf.Config(values=None, *, path=None)[source]

Represents the pelconf.yaml file.

get(name, *default)[source]

Get config value with the given name and optional default.

Parameters
  • name (str) – The name of the config value.

  • *default (Any) – If given and the key doesn’t not exist, this will be returned instead. If it’s not given and the config value does not exist, AttributeError will be raised

Return type

Any

Returns

The requested config value. This is one of the global values defined in this file. If the value does not exist it will return default if give or raise AttributeError.

Raises

AttributeError – If the value does not exist and default was not given.

get_env(name, *default)[source]

Get the value of an ENV variable.

Return type

Union[str, Any]

get_path(name, *default)[source]

Get config value as path relative to the project directory.

This allows easily defining the project configuration within the fabfile as always relative to that fabfile.

Parameters
  • name (str) – The name of the config value containing the path.

  • *default (Any) – If given and the key doesn’t not exist, this will be returned instead. If it’s not given and the config value does not exist, AttributeError will be raised

Return type

Any

Returns

The requested config value. This is one of the global values defined in this file. If the value does not exist it will return default if give or raise AttributeError.

Raises

AttributeError – If the value does not exist and default was not given.

proj_path(*path_parts)[source]

Return absolute path to the repo dir (root project directory).

Parameters

*path_parts (str) – The path relative to the project root (pelconf.yaml).

Returns

The given path converted to an absolute path.

Return type

str

reset(config)[source]

Reset config to the given values.

This will completely overwrite the current configuration.

within_proj_dir(path='.')[source]

Return an absolute path to the given project relative path.

Parameters

path (str) – Project relative path that will be converted to the system wide absolute path.

Return type

Iterator[None]

Returns

Absolute path.

exception peltak.core.conf.ConfigAlreadyInitialized[source]
exception peltak.core.conf.ConfigError[source]
exception peltak.core.conf.ConfigNotInitialized[source]
peltak.core.conf.py_import(cmd)[source]

Exists only so we can patch it in tests.

Return type

module