lisa.conf.MultiSrcConfABC#
- class lisa.conf.MultiSrcConfABC[source]#
Bases:
Serializable,ABCAbstract 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_SERIALIZATIONinheritedAttributes to be treated specially during serialization.
DEFAULT_SERIALIZATION_FMTinheritedDefault format used when serializing objects.
YAML_ENCODINGinheritedEncoding used for YAML files.
Properties
Give a mapping suitable for storing in a YAML configuration file.
loggerinheritedConvenience short-hand for
self.get_logger().Methods
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.Create a mapping of configuration classes to instance, by loading them from the list of paths using
from_yaml_map()and merging them.Write a configuration file, with the key descriptions in comments.
Return the content of the file that would be create by
to_yaml_map()in a string.__copy__()inheritedRegular shallow copy operation, without dropping any attributes.
__getstate__()inheritedFilter the instance’s attributes upon serialization.
__setstate__()inheritedfrom_path()inheritedDeserialize an object from a file.
get_logger()inheritedProvides a
logging.Loggernamed aftercls.log_locals()inheritedDebugging aid: log the local variables of the calling function.
to_path()inheritedSerialize the object to a file.
to_yaml()inheritedReturn a YAML string with the serialized object.
Attributes#
- MultiSrcConfABC.ATTRIBUTES_SERIALIZATION = {'allowed': [], 'ignored': [], 'placeholders': {}}#
Inherited attribute, see
lisa.utils.Serializable.ATTRIBUTES_SERIALIZATIONAttributes to be treated specially during serialization.
- MultiSrcConfABC.DEFAULT_SERIALIZATION_FMT = 'yaml'#
Inherited attribute, see
lisa.utils.Serializable.DEFAULT_SERIALIZATION_FMTDefault format used when serializing objects.
- MultiSrcConfABC.YAML_ENCODING = 'utf-8'#
Inherited attribute, see
lisa.utils.Serializable.YAML_ENCODINGEncoding used for YAML files.
Properties#
- property MultiSrcConfABC.as_yaml_map[source]#
Give a mapping suitable for storing in a YAML configuration file.
See also
- property MultiSrcConfABC.logger#
Inherited property, see
lisa.utils.Loggable.loggerConvenience short-hand for
self.get_logger().
Methods#
- 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:
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.
- 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.Loggernamed aftercls.
- 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.