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

set_nosquash(k, v)[source]

shortcut function: init self[k] only if v is not already set :type k: :param k: name of value to add :type k: str :type v: :param v: value to add :type v: str

to_dict()[source]

Convert the Config() to regular dict.

validate(kw)[source]

Check if the Config instance matches the expected format as declared in schemes/. As the ‘category’ is not carried by the object itself, it is provided by the function argument.

Parameters:

kw (str) – keyword describing the configuration to be validated (scheme)

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_from_profile(pf_as_dict)[source]
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_subnode(*default_subnode_dict)[source]
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.

to_dict()[source]

Convert the object to a regular dict.

Returns:

a regular Python dict

Return type:

Dict

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: