pcvs.backend.configfile module

Module for parsing configuration.

From a user persperctive, a ConfigFile is a file, gathered in a Python object information relative to the configuration of a single component. In PCVS, there is 7 types of components:

  • 5 basic blocks:

    • Compiler (defining compiler commands)

    • Runtime (setting runtime & parametrization)

    • Machine (Defining resources used for execution)

    • Group (used a templates to globally describe tests)

    • Criterion (range of parameters used to run a test-suite)

  • 2 special:

    • Profile (a group of one of each the above configuration)

    • Plugin (a python plugin)

These classes helps to manage any of these config blocks above.

class pcvs.backend.configfile.ConfigFile(config_desc)[source]

Bases: object

Handle configuration file.

Variables:
  • _raw (str) – the content of the file

  • _descriptor (ConfigDesc) – the of the current file.

Initialize a configuration file representation.

delete()[source]

Delete a configuration from disk.

Return type:

None

property descriptor: ConfigDesc

Return the description of the config file.

display()[source]

Pretty print Configuration block.

Return type:

None

edit()[source]

Open the current configuration for edition.

After eddition, the new file is loaded, check and then written to disk.

Return type:

None

property exist: bool

Return if the config file exist on disk.

flush_to_disk()[source]

Write the configuration to disk.

Also check the configuration before writing it do disk.

Return type:

None

from_str(raw)[source]

Set configuration from str.

Return type:

None

property full_name: str

Return full name.

load_from_disk()[source]

Load the configuration file to populate the current object.

Also verify the loaded content according to schema (for yml files).

Return type:

None

property loaded: bool

Return if the config is loaded in Object.

to_str()[source]

Get configuration as str.

Return type:

str

validate()[source]

Validate a Config against it’s shema.

Return type:

None

class pcvs.backend.configfile.Profile(config_desc, cl=None)[source]

Bases: YmlConfigFile

A profile represents the most complete object the user can provide.

It is built upon 5 configuration, one of each kind (compiler, runtime, machine, criterion & group) and plugins and gathers all required information to start a validation process. A profile object is the basic representation to be manipulated by the user.

Variables:
  • _config_locator (ConfigLocator) – the ConfigLocator use to locate the configurations referenced in the profile.

  • _innerconfigs (dict[str, YmlConfigFile]) – the Configuration referenced by the profile once loaded.

Initialize a profile.

Parameters:
  • config_desc (ConfigDesc) – The config Descriptor for the profile file.

  • cl (ConfigLocator | None) – A ConfigLocator Object used to locat config specify by Profile.

CONFIGS_KINDS = [COMPILER, CRITERION, GROUP, MACHINE, RUNTIME]
property compiler: Config

Access the ‘compiler’ section.

Returns:

the ‘compiler’ config

property criterion: Config

Access the ‘criterion’ section.

Returns:

the ‘criterion’ config

property group: Config

Access the ‘group’ section.

Returns:

the ‘group’ config

property machine: Config

Access the ‘machine’ section.

Returns:

the ‘machine’ config

property runtime: Config

Access the ‘runtime’ section.

Returns:

the ‘runtime’ config

class pcvs.backend.configfile.YmlConfigFile(config_desc)[source]

Bases: ConfigFile

A Yaml File Configuration.

Variables:

_details (dict) – the yaml representation of the configuration.

Initialize a Yaml configuration file representation.

property config: Config

Get config object associated with config file.

Returns:

the config object associated with the config file.

from_dict(d)[source]

Fill the config from the raw parameter.

Content of the dictionary is check to ensure it respect yaml template associated with configuration file. File is not written to disk.

Parameters:

d (dict) – the dictionary to be impoted.

Return type:

None

to_dict()[source]

Convert the Config() to regular dict.

Return type:

dict

pcvs.backend.configfile.get_conf(cd)[source]

Get Appropriate ConfigFile Object from a ConfigDesc.

Return type:

ConfigFile