Configuration files

Repository.config

The configuration file for this repository

If a the configuration hasn’t been set yet, the default config for repository will be returned, including global and system configurations (if they are available).

The Config type

static Config.get_system_config() → Config

Return an object representing the system configuration file.

static Config.get_global_config() → Config

Return an object representing the global configuration file.

Config.add_file(path, level=0, force=0)

Add a config file instance to an existing config.

Config.get_multivar(name[, regex]) → [str, ...]

Get each value of a multivar ‘’name’’ as a list. The optional ‘’regex’’ parameter is expected to be a regular expression to filter the variables we’re interested in.

Config.set_multivar(name, regex, value)

Set a multivar ‘’name’’ to ‘’value’‘. ‘’regexp’’ is a regular expression to indicate which values to replace

Config.__iter__()

The Config class has an iterator which can be used to loop through all the entries in the configuration. Each element is a tuple containing the name and the value of each configuration variable. Be aware that this may return multiple versions of each entry if they are set multiple times in the configuration files.

The Config Mapping interface.

When using the mapping interface, the value is returned as a string. In order to apply the git-config parsing rules, you can use Config.get_bool() or Config.get_int().

Config.get_bool(key) → Bool

Look up key and parse its value as a boolean as per the git-config rules

Truthy values are: ‘true’, 1, ‘on’ or ‘yes’. Falsy values are: ‘false’, 0, ‘off’ and ‘no’

Config.get_int(key) → int

Look up key and parse its value as an integer as per the git-config rules.

A value can have a suffix ‘k’, ‘m’ or ‘g’ which stand for ‘kilo’, ‘mega’ and ‘giga’ respectively