confab.merge

Configuration data structure merging functions.

We expect to obtain hierarchical configurations as native dictionaries and want to merge the higher precedence (override) data into the lower precedence (default) data, potentially multiple times.

Merge rules are as follows:
  • Dictionaries are merged recursively by default.
  • Lists and primitives are replaced by default.
  • Callables are called to provide custom extension.

For example, a list of hosts in the default dictionary will normally be replaced by values defined in the override dictionary; however if the override dictionary’s list is a callable, it can be made to do something else, such as append a new host to the default list.

class confab.merge.Append(*args)[source]

Bases: list

Customized callable list that appends its values to the default.

class confab.merge.Prepend(*args)[source]

Bases: list

Customized callable list that prepends its values to the default.

class confab.merge.UniqueUnion(*args)[source]

Bases: list

Customized callable list that adds its values to the default list preserving unique values.

confab.merge.merge(*args)[source]

Recursively merge multiple dictionaries.