lisa.conf.KeyDesc#

class lisa.conf.KeyDesc(name, help, classinfo, newtype=None, deepcopy_val=True)[source]#

Bases: KeyDescBase

Key descriptor describing a leaf key in the configuration.

Parameters:
  • name – Name of the key

  • help – Short help message describing the use of that key

  • classinfo (collections.abc.Sequence) – sequence of allowed types for that key. As a special case, None is allowed in that sequence of types, even though it is not strictly speaking a type.

  • newtype (str or None) – If specified, a type with the given name will be created for that key with that name. Otherwise, a camel-case name derived from the key name will be used: toplevel-key/sublevel/mykey will give a type named SublevelMykey. This class will be exposed as an attribute of the parent MultiSrcConf (which is why the toplevel key is omitted from its name). A getter will also be created on the parent configuration class, so that the typed key is exposed to exekall. If the key is not present in the configuration object, the getter will return None.

  • deepcopy_val (bool) – If True, the values will be deepcopied upon lookup. This prevents accidental modification of mutable types (like lists) by the user.

Attributes

help inherited

Help description associated with the key.

name inherited

Name of that key.

parent inherited

Parent LevelKeyDesc.

Properties

newtype

Unique type associated with that key.

path inherited

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

qualname inherited

Qualified name of the configuration key used for error reporting.

Methods

get_help()

Get a help message describing the key.

pretty_format()

Format the value for pretty printing.

validate_val()

Check that the value is an instance of one of the type specified in the self.classinfo.

Attributes#

KeyDesc.help#

Inherited attribute, see lisa.conf.KeyDescBase.help

Help description associated with the key.

KeyDesc.name#

Inherited attribute, see lisa.conf.KeyDescBase.name

Name of that key.

KeyDesc.parent#

Inherited attribute, see lisa.conf.KeyDescBase.parent

Parent LevelKeyDesc.

Properties#

property KeyDesc.newtype[source]#

Unique type associated with that key.

This allows refering unambiguously to the type of a configuration key, linking directly a type annotation to the value of a specific key.

property KeyDesc.path#

Inherited property, see lisa.conf.KeyDescBase.path

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

property KeyDesc.qualname#

Inherited property, see lisa.conf.KeyDescBase.qualname

Qualified name of the configuration key used for error reporting.

Methods#

KeyDesc.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.

static KeyDesc.pretty_format(v)[source]#

Format the value for pretty printing.

Parameters:

v (object) – Value of the key that is being printed

Returns:

A string

KeyDesc.validate_val(val)[source]#

Check that the value is an instance of one of the type specified in the self.classinfo.

If the value is not an instance of any of these types, then a TypeError is raised corresponding to the first type in the tuple, which is assumed to be the main one.