Configuration Utilities

A module that defines common configuration utility functions.

munet.config.list_to_dict_with_key(lst, k)

Convert a YANG styl list of objects to dict of objects.

This function converts a YANG style list of objects (dictionaries) to a plain python dictionary of objects (dictionaries). The value for the supplied key for each object is used to store the object in the new diciontary.

This only works for lists of objects which are keyed on a single contained value.

Parameters:
  • lst – a list of python dictionary objects.

  • k – the key value contained in each dictionary object in the list.

Returns:

A dictionary of objects (dictionaries).

munet.config.config_to_dict_with_key(c, ck, k)

Convert the config item from a list of objects to dict.

Use list_to_dict_with_key() to convert the list of objects at c[ck] to a dict of the objects using the key k.

Parameters:
  • c – config dictionary

  • ck – The key identifying the list of objects from c.

  • k – The key to pass to list_to_dict_with_key().

Returns:

A dictionary of objects (dictionaries).

munet.config.value_merge_deepcopy(s1, s2)

Merge values using deepcopy.

Create a deepcopy of the result of merging the values from dicts s1 and s2. If a key exists in both s1 and s2 the value from s2 is used.”

class munet.config.ConfigOptionsProxy(pytestconfig=None)

Proxy options object to fill in for any missing pytest config.

class DefNoneObject

An object that returns None for any attribute access.