Configuration

class ase2sprkkr.common.configuration.Configuration(definition, container=None)[source]

The common base class for all configurations values and containers. I.e. for Options and Sections.

Class hierarchy

Inheritance diagram of ase2sprkkr.common.configuration.Configuration

Constructor

__init__(definition, container=None)[source]

Create the object. Just sets the two properties from the parameters.

Parameters
_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 the CONTROL section has the path CONTROL.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.

as_dict(only_changed='basic')[source]

Return the value of self, in the case of container as a dictionary. To be redefined in the descendants.

Parameters

only_changed (Union[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 changed expert values.

to_dict(only_changed='basic')[source]

Alias of the method as_dict().

Parameters

only_changed (Union[bool, str]) –

show()[source]

Print the configuration, as it will be saved into the configuration/problem definition file.

property info
property doc
help(verbose=False, show_hidden=False)[source]
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 (Union[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 value True), use set to allow some missing values.