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:
- check(allow_conversion=True)[source]
Validate a single configuration block according to its scheme.
- Return type:
- 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:
- 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:
- 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.
- property full_name: str
Return complete block label (scope + kind + name)
- Returns:
the fully-qualified name.
- Return type:
- is_found()[source]
Check if the current config block is present on fs.
- Returns:
True if it exists
- Return type:
- load_from_disk()[source]
load the configuration file to populate the current object.
- Raises:
BadTokenError – the scope/kind/name tuple does not refer to a valid file.
NotFoundError – The target file does not exist
- Return type:
- load_template(name=None)[source]
load from the specific template, to create a new config block
- Return type:
- property ref_file: str
Return filepath associated with current config block.
- Returns:
the filepath, may be None
- Return type:
- 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:
BadTokenError – Kind is None
BadTokenError – Kind is not in allowed values.
- Return type:
- 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:
- 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 (seeCONFIG_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