Configuration
- class ase2sprkkr.ase.test.configuration.Configuration(definition, container=None)[source]
The common base class for all configurations values and containers. I.e. for
Options
andSections
.Class hierarchy
Constructor
- __init__(definition, container=None)[source]
Create the object. Just sets the two properties from the parameters.
- Parameters:
definition (ase2sprkkr.common.configuration_definitions.BaseDefinition) – Definition of this configuration object.
container (ase2sprkkr.common.configuration_containers.ConfigurationContainer) – The container, that owns this configuration object.
- _definition
The “definition” of the option or section. The definition determines the name(s), value type(s) etc… contained in the configuration object. Instance of
ase2sprkkr.common.configuration_definitions.BaseDefinition
- _container
The parent container. I.e. the container that holds this object (e.g. for a value it is the section that owns the value) Instance of
ase2sprkkr.common.configuration_containers.ConfigurationContainer
- _get_path(include_root=False)[source]
Return the dot-delimited path to the item in the configuration tree.
E.g. the
ENERGY
option in theCONTROL
section has the pathCONTROL.ENERGY
- _get_root_container()[source]
Return the root object of the configuration tree.
I.E. the object, that represents the whole configuration or problem-definition file
- property name
Return the name of the option/section. The name is defined by the definition of the object.
- Returns:
name (str)
The name of the object.
- static as_dict_getter(only_changed='basic', generated=False, copy=False)[source]
- Parameters:
only_changed (bool | str)
- as_dict(only_changed='basic', generated=False, copy=False, getter=None)[source]
Return the value of self, in the case of container as a dictionary. To be redefined in the descendants.
- Parameters:
only_changed (bool | str) – Return only changed values, or all of them? If True, return only the values, that differ from the defaults. If False, return all the values. The default value
basic
means, return all non-expert values and all the changed expert values.explicit
means just the values, that were explicitly set (even if they are the same as the default value)
- to_dict(only_changed='basic', generated=False, copy=False, getter=None)
Return the value of self, in the case of container as a dictionary. To be redefined in the descendants.
- Parameters:
only_changed (bool | str) – Return only changed values, or all of them? If True, return only the values, that differ from the defaults. If False, return all the values. The default value
basic
means, return all non-expert values and all the changed expert values.explicit
means just the values, that were explicitly set (even if they are the same as the default value)
- show()[source]
Print the configuration, as it will be saved into the configuration/problem definition file.
- property info
- property doc
- save_to_file(file, *, validate='save')[source]
Save the configuration to a file in a given format.
This routine do some basic stuff and then call _save_to_file routine, that contains the implementation specific for the type of the configuration container/value.
- Parameters:
file (str or file) – File to read the data from
validate (str | bool) – Validate the data in the container first and raise an exception, if there is an error (e.g. the the data are not complete). The string value can be used to select the type of validation
save
means the full check (same as the default valueTrue
), useset
to allow some missing values.
- to_string(*, validate='warning')[source]
Return the configuration (problem definition) in a string.
- Parameters:
method (Validate. How to validate before retrieving. See the)
validate.
'save' (Default 'warning' means the same as)
warning. (but only throw a)
validate (str | bool)
- Returns:
configuration (str)
The configuration, as it should be saved in a configuration/problem definition file.