pcvs.helpers.system module
- class pcvs.helpers.system.Config(d={}, *args, **kwargs)[source]
Bases:
MetaDict
a ‘Config’ is a dict extension (an MetaDict), used to manage all configuration fields. While it can contain arbitrary data, the whole PCVS configuration is composed of 5 distinct ‘categories’, each being a single Config. These are then gathered in a MetaConfig object (see below)
- from_dict(d)[source]
Fill the current Config from a given dict :type d: :param d: dictionary to add :type d: dict
- from_file(filename)[source]
Fill the current config from a given file
- Raises:
CommonException.IOError – file does not exist OR badly formatted
- set_ifdef(k, v)[source]
shortcut function: init self[k] only if v is not None :type k: :param k: name of value to add :type k: str :type v: :param v: value to add :type v: str
- class pcvs.helpers.system.MetaConfig(*args, **kwargs)[source]
Bases:
MetaDict
Root configuration object. It is composed of Config(), categorizing each configuration blocks. This MetaConfig() contains the whole profile along with any validation and current run information. This configuration is used as a dict extension.
To avoid carrying a global instancied object over the whole code, a class-scoped attribute allows to browse the global configuration from anywhere through Metaconfig.root”
- bootstrap_compiler(node)[source]
“Specific initialize for compiler config block :type node: :param node: compiler block to initialize :type node: dict :return: added node :rtype: dict
- bootstrap_criterion(node)[source]
“Specific initialize for criterion config block :type node: :param node: criterion block to initialize :type node: dict :return: initialized node :rtype: dict
- bootstrap_generic(subnode, node)[source]
“Initialize a Config() object and store it under name ‘node’ :type subnode: :param subnode: node name :type subnode: str :type node: :param node: node to initialize and add :type node: dict :return: added subnode :rtype: dict
- bootstrap_group(node)[source]
“Specific initialize for group config block. There is currently nothing to here but calling bootstrap_generic() :type node: :param node: runtime block to initialize :type node: dict :return: added node :rtype: dict
- bootstrap_machine(node)[source]
“Specific initialize for machine config block :type node: :param node: machine block to initialize :type node: dict :return: initialized node :rtype: dict
- bootstrap_runtime(node)[source]
“Specific initialize for runtime config block :type node: :param node: runtime block to initialize :type node: dict :return: added node :rtype: dict
- bootstrap_validation(node)[source]
“Specific initialize for validation config block :type node: :param node: validation block to initialize :type node: dict :return: initialized node :rtype: dict
- bootstrap_validation_from_file(filepath)[source]
Specific initialize for validation config block. This function loads a file containing the validation dict.
- Parameters:
filepath (os.path, str) – path to file to be validated
- Raises:
CommonException.IOError – file is not found or badly formatted
- dump_for_export()[source]
Export the whole configuration as a dict. Prune any __internal node beforehand.
- get_internal(k)[source]
manipulate the internal MetaConfig() node to load not-exportable data :type k: :param k: value to get :type k: str
- root = None
- set_internal(k, v)[source]
manipulate the internal MetaConfig() node to store not-exportable data :type k: :param k: name of value to add :type k: str :type v: :param v: value to add :type v: str
- validation_default_file = '/home/docs/.pcvs/validation.yml'
- class pcvs.helpers.system.MetaDict(*args, **kwargs)[source]
Bases:
Dict
Helps with managing large configuration sets, based on dictionaries.
Once instanciated, an arbitraty subnode can be initialized like:
o = MetaDict() o.field_a.subnode2 = 4
Currently, this class is just derived from addict.Dict. It is planned to remove this adherence.
- class pcvs.helpers.system.ValidationScheme(name)[source]
Bases:
object
Object manipulating schemes (yaml) to enforce data formats. A validationScheme is instancied according to a ‘model’ (the format to validate). This instance can be used multiple times to check multiple streams belonging to the same model.
- avail_list = None
- classmethod available_schemes()[source]
return list of currently supported formats to be validated. The list is extracted from INSTALL/schemes/<model>-scheme.yml
- validate(content, filepath=None)[source]
Validate a given datastructure (dict) agasint the loaded scheme.
- Parameters:
content (dict) – json to validate
filepath –
- Raises:
ValidationException.FormatError – data are not valid
ValidationException.SchemeError – issue while applying scheme