pkglts.config_management module

Main config object and functions to manipulate it.

class pkglts.config_management.Config(*args, **kwds)[source]

Bases: dict

Object used to store both a templated version of the config as a dict interface its resolution and a jinja2 environment that reflect the config.

add_test(name, func)[source]

Add a new test in jinja2 environment.

Parameters:
  • name (str) – name of test (must be unique)

  • func (callable) – function use for test

Returns:

None

installed_options(return_sorted=False)[source]

List all installed options.

Returns:

(iter of str)

load_extra()[source]

load option specific handlers.

Returns:

None

render(txt)[source]

Use items in config to render text

Parameters:

txt (str) – templated text to render

Returns:

same text where all templated parts have been replaced

by their values.

Return type:

(str)

resolve()[source]

Try to resolve all templated items.

Returns:

None

template()[source]

Associated template even after resolution.

class pkglts.config_management.ConfigSection[source]

Bases: object

Small class to allow accessing parameters using the dot method instead of [‘param_name’] method

pkglts.config_management.get_pkg_config(rep='.')[source]

Read pkg_cfg file associated to this package.

Parameters:

rep (Path) – directory to search for info

Returns:

Config initialized with pkg_config

Return type:

(Config)

pkglts.config_management.upgrade_pkg_cfg_version(pkg_cfg, version)[source]

Upgrade the version of pkg_cfg file from version to version +1

Parameters:
  • pkg_cfg (dict of str, any) – package configuration

  • version (int) – current version of file

Returns:

any): a reference to an updated pkg_cfg

Return type:

(dict of str

pkglts.config_management.write_pkg_config(cfg, rep='.')[source]

Store config associated to this package on disk.

Parameters:
  • cfg (Config) – current working config

  • rep (Path) – directory to search for info

Returns:

None