lisa.conf.MultiSrcConfABC#

class lisa.conf.MultiSrcConfABC[source]#

Bases: Serializable, ABC

Abstract Base Class of MultiSrcConf.

Warning

Arbitrary code can be executed while loading an instance from a YAML or Pickle file. To include untrusted data in YAML, use the !untrusted tag along with a string

Attributes

ATTRIBUTES_SERIALIZATION inherited

Attributes to be treated specially during serialization.

DEFAULT_SERIALIZATION_FMT inherited

Default format used when serializing objects.

YAML_ENCODING inherited

Encoding used for YAML files.

Properties

as_yaml_map

Give a mapping suitable for storing in a YAML configuration file.

logger inherited

Convenience short-hand for self.get_logger().

Methods

from_map()

from_yaml_map()

Allow reloading from a plain mapping, to avoid having to specify a tag in the configuration file. The content is hosted under the top-level key specified in STRUCTURE.

from_yaml_map_list()

Create a mapping of configuration classes to instance, by loading them from the list of paths using from_yaml_map() and merging them.

to_map()

to_yaml_map()

Write a configuration file, with the key descriptions in comments.

to_yaml_map_str()

Return the content of the file that would be create by to_yaml_map() in a string.

__copy__() inherited

Regular shallow copy operation, without dropping any attributes.

__getstate__() inherited

Filter the instance’s attributes upon serialization.

__setstate__() inherited

from_path() inherited

Deserialize an object from a file.

get_logger() inherited

Provides a logging.Logger named after cls.

log_locals() inherited

Debugging aid: log the local variables of the calling function.

to_path() inherited

Serialize the object to a file.

to_yaml() inherited

Return a YAML string with the serialized object.

Attributes#

MultiSrcConfABC.ATTRIBUTES_SERIALIZATION = {'allowed': [], 'ignored': [], 'placeholders': {}}#

Inherited attribute, see lisa.utils.Serializable.ATTRIBUTES_SERIALIZATION

Attributes to be treated specially during serialization.

MultiSrcConfABC.DEFAULT_SERIALIZATION_FMT = 'yaml'#

Inherited attribute, see lisa.utils.Serializable.DEFAULT_SERIALIZATION_FMT

Default format used when serializing objects.

MultiSrcConfABC.YAML_ENCODING = 'utf-8'#

Inherited attribute, see lisa.utils.Serializable.YAML_ENCODING

Encoding used for YAML files.

Properties#

property MultiSrcConfABC.as_yaml_map[source]#

Give a mapping suitable for storing in a YAML configuration file.

property MultiSrcConfABC.logger#

Inherited property, see lisa.utils.Loggable.logger

Convenience short-hand for self.get_logger().

Methods#

abstract classmethod MultiSrcConfABC.from_map(mapping, add_default_src=True)[source]#
classmethod MultiSrcConfABC.from_yaml_map(path, add_default_src=True)[source]#

Allow reloading from a plain mapping, to avoid having to specify a tag in the configuration file. The content is hosted under the top-level key specified in STRUCTURE.

Parameters:
  • path (str) – Path to the YAML file

  • add_default_src (bool) – Add a default source if available for that class.

Note

Only load YAML files from trusted source as it can lead to arbitrary code execution.

classmethod MultiSrcConfABC.from_yaml_map_list(path_list, add_default_src=True)[source]#

Create a mapping of configuration classes to instance, by loading them from the list of paths using from_yaml_map() and merging them.

Parameters:
  • path_list (list(str)) – List of paths to YAML configuration files.

  • add_default_src – See from_yaml_map().

Note

When merging, the configuration coming from the rightmost path will win if it defines some keys that were also defined in another file. Each file will be mapped to a different sources, named after the basename of the file.

Note

Only load YAML files from trusted source as it can lead to arbitrary code execution.

abstract MultiSrcConfABC.to_map()[source]#
MultiSrcConfABC.to_yaml_map(path)[source]#

Write a configuration file, with the key descriptions in comments.

Parameters:

path (str) – Path to the file to write to.

MultiSrcConfABC.to_yaml_map_str(**kwargs)[source]#

Return the content of the file that would be create by to_yaml_map() in a string.

Variable keyword arguments:

Forwarded to to_yaml_map()

MultiSrcConfABC.__copy__()#

Inherited method, see lisa.utils.Serializable.__copy__()

Regular shallow copy operation, without dropping any attributes.

MultiSrcConfABC.__getstate__()#

Inherited method, see lisa.utils.Serializable.__getstate__()

Filter the instance’s attributes upon serialization.

MultiSrcConfABC.__setstate__(dct)#

Inherited method, see lisa.utils.Serializable.__setstate__()

classmethod MultiSrcConfABC.from_path(filepath, fmt=None)#

Inherited method, see lisa.utils.Serializable.from_path()

Deserialize an object from a file.

classmethod MultiSrcConfABC.get_logger(suffix=None)#

Inherited method, see lisa.utils.Loggable.get_logger()

Provides a logging.Logger named after cls.

classmethod MultiSrcConfABC.log_locals(var_names=None, level='debug')#

Inherited method, see lisa.utils.Loggable.log_locals()

Debugging aid: log the local variables of the calling function.

MultiSrcConfABC.to_path(filepath, fmt=None)#

Inherited method, see lisa.utils.Serializable.to_path()

Serialize the object to a file.

MultiSrcConfABC.to_yaml()#

Inherited method, see lisa.utils.Serializable.to_yaml()

Return a YAML string with the serialized object.