lisa.conf.KeyDescBase#

class lisa.conf.KeyDescBase(name, help)[source]#

Bases: ABC

Base class for configuration files key descriptor.

This allows defining the structure of the configuration file, in order to sanitize user input and generate help snippets used in various places.

Attributes

help

Help description associated with the key.

name

Name of that key.

parent

Parent LevelKeyDesc.

Properties

path

Path in the config file from the root to that key.

qualname

Qualified name of the configuration key used for error reporting.

Methods

get_help()

Get a help message describing the key.

validate_val()

Validate a value to be used for that key.

Attributes#

KeyDescBase.help#

Help description associated with the key.

KeyDescBase.name#

Name of that key.

KeyDescBase.parent#

Parent LevelKeyDesc.

Properties#

property KeyDescBase.path[source]#

Path in the config file from the root to that key.

This path is a list of strings, one item per level.

Note

This includes the top-level key name, which must be removed before it’s fed to MultiSrcConf.get_nested_key().

property KeyDescBase.qualname[source]#

Qualified name of the configuration key used for error reporting.

This is a slash-separated path in the config file from the root to that key following the pattern <parent qualname>/<name>.

Methods#

abstract KeyDescBase.get_help(style=None, last=False, children=True)[source]#

Get a help message describing the key.

Parameters:
  • style – When “rst”, ResStructuredText formatting may be applied

  • style – str

  • last (bool) – True if this is the last item in a list.

  • children (bool) – If True, include the help of any children of the current level.

abstract KeyDescBase.validate_val(val)[source]#

Validate a value to be used for that key.

Raises:
  • TypeError – When the value has the wrong type

  • ValueError – If the value does not comply with some other constraints. Note that constraints should ideally be encoded in the type itself, to make help message as straightforward as possible.