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() None[source]

Validate a single configuration block according to its scheme.

clone(clone: ConfigurationBlock) None[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

delete() None[source]

Delete a configuration block from disk

display() None[source]

Configuration block pretty printer

dump() dict[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(e=None) None[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.

edit_plugin(e=None) None[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

fill(raw) None[source]

Populate the block content with parameters.

Parameters

raw (dict) – the data to fill.

flush_to_disk() None[source]

write the configuration block to disk

property full_name: str

Return complete block label (scope + kind + name)

Returns

the fully-qualified name.

Return type

str

is_found() bool[source]

Check if the current config block is present on fs.

Returns

True if it exists

Return type

bool

load_from_disk() None[source]

load the configuration file to populate the current object.

Raises
load_template(name=None) None[source]

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

property ref_file: str

Return filepath associated with current config block.

Returns

the filepath, may be None

Return type

str

retrieve_file() None[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())

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
pcvs.backend.config.init() None[source]

Load configuration tree available on disk.

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

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