pcvs.backend.config module

class pcvs.backend.config.ConfigurationBlock(kind, name, scope=None)[source]

Bases: object

Handle the basic configuration block, smallest part of a profile.

From a user persperctive, a basic block is a dict, gathering in a Python object informations relative to the configuration of a single component. In PCVS, there is 5 types of components:

  • Compiler-oriented (defining compiler commands)

  • Runtime-oriented (setting runtime & parametrization)

  • Machine-oriented (Defining resources used for execution)

  • Group-oriented (used a templates to globally describe tests)

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

This class helps to manage any of these config blocks above. The distinction between them is carried over by an instance attribute _kind.

Note

This object can easily be confused with system.Config. While ConfigurationBlocks are from a user perspective, system.Config handles the internal configuration tree, on which runs rely. Nonetheless, both could be merged into a single representation in later versions.

Parameters:
  • _kind (str) – which component this object describes

  • _name (str) – block name

  • details (dict) – block content

  • _scope (str) – block scope, may be None

  • _file (str) – absolute path for the block on disk

  • _exists (bool) – True if the block exist on disk

check(allow_conversion=True)[source]

Validate a single configuration block according to its scheme.

Return type:

None

clone(clone)[source]

Copy the current object to create an identical one.

Mainly used to mirror two objects from different scopes.

Parameters:

clone (ConfigurationBlock) – the object to mirror

Return type:

None

delete()[source]

Delete a configuration block from disk

Return type:

None

display()[source]

Configuration block pretty printer

Return type:

None

dump()[source]

Convert the configuration Block to a regular dict.

This function first load the last version, to ensure being in sync.

Returns:

a regular dict() representing the config blocK

Return type:

dict

edit()[source]

Open the current block for edition.

Raises:

Exception – Something occured on the edited version.

Parameters:

e (str) – the EDITOR to use instead of default.

Return type:

None

edit_plugin()[source]

Special case to handle ‘plugin’ key for ‘runtime’ blocks.

This allows to edit a de-serialized version of the ‘plugin’ field. By default, data are stored as a base64 string. In order to let user edit the code, the string need to be decoded first.

Parameters:

e (str) – the editor to use instead of defaults

Return type:

None

fill(raw)[source]

Populate the block content with parameters.

Parameters:

raw (dict) – the data to fill.

Return type:

None

flush_to_disk()[source]

write the configuration block to disk

Return type:

None

property full_name: str

Return complete block label (scope + kind + name)

Returns:

the fully-qualified name.

Return type:

str

is_found()[source]

Check if the current config block is present on fs.

Returns:

True if it exists

Return type:

bool

load_from_disk()[source]

load the configuration file to populate the current object.

Raises:
Return type:

None

load_template(name=None)[source]

load from the specific template, to create a new config block

Return type:

None

property ref_file: str

Return filepath associated with current config block.

Returns:

the filepath, may be None

Return type:

str

retrieve_file()[source]

Associate the actual filepath to the config block.

From the stored kind, scope, name, attempt to detect configuration block on the file system (i.e. detected during module init())

Return type:

None

property scope: str

Return block scope.

Returns:

the scope, resolved if needed.

Return type:

str

property short_name: str

Return the block label only.

Returns:

the short name (may conflict with other config block)

Return type:

str

pcvs.backend.config.check_valid_kind(s)[source]

Assert the parameter is a valid kind.

Kind are defined by CONFIG_BLOCKS module attribute.

Parameters:

s (str) – the kind to validate

Raises:
Return type:

bool

pcvs.backend.config.init()[source]

Load configuration tree available on disk.

This function is called when PCVS starts to load 3-scope configuration trees.

Return type:

None

pcvs.backend.config.list_blocks(kind, scope=None)[source]

Get available configuration blocks, as present on disk.

Parameters:
  • kind (str, one of CONFIG_BLOCKS values) – configBlock kind (see CONFIG_BLOCKS for possible values)

  • scope ('user', 'global' or 'local', optional) – where the configblocks is located, defaults to None

Returns:

list blocks with specified kind, restricted by scope (if any)

Return type:

dict of config blocks

pcvs.backend.config.list_templates()[source]

List available templates to be used for boostraping config. blocks.

Returns:

a list of valid templates.

Return type:

list