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
|
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 |
|
Converts a configData class back into a standard Python class :param data: configData, i.e. configList, configDict. |
|
Converts a known class to a configClass, that can additionally store attributes :param data: |
|
|
|
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. |
|
Checks if the template is valid :param template: dictionary |
Classes
|
The class is a modified dictionary that allows to add attributes. |
|
The class is a modified list that allows to add attributes. |
|
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. |
|
The class is a modified dictionary that allows to add attributes. |
|
The class is a modified dictionary with extra functionality for configuration. |