redvypr.config

redvypr configuration module

The module provides modified objects that allow to store extra attributes. - dict - list - str, todo - int, todo - float, todo - bool, todo - None, todo

Templates can be used to define the configuration A template is a dict with the keys defining entries that can be configured. Options are for lists and dicts datatypes that can be added, for int, float, str the values of the variable .. code-block:

config_template['list_options'] = {'type': 'list', 'options': ['int','float']}
config_template['int_options'] = {'type': 'int', 'options': [4,5,6]}

As option also other templates can be used

template_option = {}
template_option['template_name'] = 'option1'
template_option['port'] = {'type': 'int'}

config_template['template_name'] = 'test_template'
config_template['list_options'] = {'type': 'list', 'options': ['int',template_option]}

Functions

apply_config_to_configDict(userconfig, ...)

Applies a user configuration to a dictionary created from a template :param userconfig: The configuration dictionary :param configdict: The dictionary the configuration will be applied to

configdata_to_data(data)

Converts a configData class back into a standard Python class :param data: configData, i.e. configList, configDict.

data_to_configdata(data[, recursive])

Converts a known class to a configClass, that can additionally store attributes :param data:

deepcopy_config(data[, standard_datatypes])

param data:

the data to be copied

dict_to_configDict(data[, process_template, ...])

creates a config dictionary out of a configuration template, the values of the dictionary are configList/configNumber objects that can be accessed like classical values but have the capability to store attributes as well.

valid_template(template)

Checks if the template is valid :param template: dictionary

Classes

configDict([dict])

The class is a modified dictionary that allows to add attributes.

configList([initlist])

The class is a modified list that allows to add attributes.

configNumber([n])

Emulate numeric types based on "n" attribute, based on https://docs.python.org/3/reference/datamodel.html#basic-customization https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types This is effectively a mutable container for a number, and can be subclassed to provide interesting properties that are related to the number.

configString(seq)

The class is a modified dictionary that allows to add attributes.

configuration([template, config])

The class is a modified dictionary with extra functionality for configuration.