pcvs.backend.profile module

class pcvs.backend.profile.Profile(name, scope=None)[source]

Bases: object

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

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

Note

A profile object can be confused with pcvs.helpers.system.MetaConfig. While both are carrying the whole user configuration, a Profile object is used to build/manipulate it, while a Metaconfig is the actual internal representation of a complete run config.

Parameters
  • _name (str) – profile name, should be unique for a given scope

  • _scope (str) – profile scope, allowed values in storage_order(), defaults to None

  • _exists (bool) – return True if the profile exists on disk.

  • _file (str) – profile file absolute path

check()[source]

Ensure profile meets scheme requirements, as a concatenation of 5 configuration block schemes.

Raises

FormatError – A ‘kind’ is missing from profile OR incorrect profile.

clone(clone)[source]

Duplicate a valid profile into the current one.

Parameters

clone (Profile) – a valid profile object

property compiler

Access the ‘compiler’ section.

Returns

the ‘compiler’ dict segment

Return type

dict

property criterion

Access the ‘criterion’ section.

Returns

the ‘criterion’ dict segment

Return type

dict

delete()[source]

Remove the current profile from disk.

It does not destroy the Python object, though.

display()[source]

Display profile data into stdout/file.

dump()[source]

Return the full profile content as a single regular dict.

This function loads the profile on disk first.

Returns

a regular dict for this profile

Return type

dict

edit(e=None)[source]

Open the editor to manipulate profile content.

Parameters

e (str) – an editor program to use instead of defaults

Raises

Exception – Something happened while editing the file

Warning

If the edition failed (validation failed) a rejected file is created in the current directory containing the rejected profile. Once manually edited, it may be submitted again through pcvs profile import.

edit_plugin(e=None)[source]

Edit the ‘runtime.plugin’ section of the current profile.

Parameters

e (str) – an editor program to use instead of defaults

Raises

Exception – Something happened while editing the file.

Warning

If the edition failed (validation failed) a rejected file is created in the current directory containing the rejected profile. Once manually edited, it may be submitted again through pcvs profile import.

fill(raw)[source]

Update the given profile with content stored in parameter.

Parameters

raw (dict) – tree of (key, values) pairs to update

flush_to_disk()[source]

Write down profile to disk.

Also, ensure the filepath is valid and profile content is compliant with schemes.

property full_name

Return fully-qualified profile name (scope + name).

Returns

the unique profile name.

Return type

str

get_unique_id()[source]

Compute unique hash string identifying a profile.

This is required to make distinction between multiple profiles, based on its content (banks relies on such unicity).

Returns

an hashed version of profile content

Return type

str

property group

Access the ‘group’ section.

Returns

the ‘group’ dict segment

Return type

dict

is_found()[source]

Check if the current profile exists on disk.

Returns

True if the file exist on disk

Return type

bool

load_from_disk()[source]

Load the profile from its representation on disk.

Raises
load_template(name='default')[source]

Populate the profile from templates of 5 basic config. blocks.

Filepath still need to be determined via retrieve_file() call.

property machine

Access the ‘machine’ section.

Returns

the ‘machine’ dict segment

Return type

dict

property runtime

Access the ‘runtime’ section.

Returns

the ‘runtime’ dict segment

Return type

dict

property scope

Return the profile scope.

Returns

profile scope

Return type

str

split_into_configs(prefix, blocklist, scope=None)[source]

Convert the given profile into a list of basic blocks.

This is the reverse operation of creating a profile (not the ‘opposite’).

Parameters
  • prefix (str) – common prefix name used to name basic blocks.

  • blocklist (list) – list of config.blocks to generate (all 5 by default but can be retrained)

  • scope (str, optional) – config block scope, defaults to None

Raises

AlreadyExistError – the created configuration block name already exist

Returns

list of created ConfigurationBlock

Return type

list

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

Initialization callback, loading available profiles on disk.

pcvs.backend.profile.list_profiles(scope=None)[source]

Return a list of valid profiles found on disk.

Parameters

scope (str, optional) – restriction on scope, defaults to None

Returns

dict of 3 dicts (‘user’, ‘local’ & ‘global’) or a single dict (if ‘scope’ was set), containing, for each profile name, the filepath.

Return type

dict

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

List available templates to be used for boostraping profiles.

Returns

a list of valid templates.

Return type

list