ConfigurationValueDefinition

class ase2sprkkr.sprkkr.configuration.ConfigurationValueDefinition(name, type=None, default_value=None, default_value_from_container=None, written_name=None, alternative_names=None, fixed_value=None, required=None, init_by_default=False, result_is_visible=False, info=None, description=None, is_stored=None, is_hidden=False, is_optional=None, is_expert=False, is_numbered_array=False, is_repeated=False, is_always_added=None, name_in_grammar=None, name_format=None, expert=None, write_alternative_name=False, write_condition=None, condition=None, result_class=None)[source]

Definition o a configuration value, used in SPRKKR configuration file.

Class hierarchy

Inheritance diagram of ase2sprkkr.sprkkr.configuration.ConfigurationValueDefinition

Constructor

Parameters:
  • is_numbered_array (bool) –

  • is_always_added (bool) –

  • write_alternative_name (bool) –

__init__(name, type=None, default_value=None, default_value_from_container=None, written_name=None, alternative_names=None, fixed_value=None, required=None, init_by_default=False, result_is_visible=False, info=None, description=None, is_stored=None, is_hidden=False, is_optional=None, is_expert=False, is_numbered_array=False, is_repeated=False, is_always_added=None, name_in_grammar=None, name_format=None, expert=None, write_alternative_name=False, write_condition=None, condition=None, result_class=None)

Definition of a configuration value.

Parameters:
  • name (str) – Name of the configuration value

  • type (Optional[GrammarType|mixed]) – Configuration value data type. If it is set to anyting what is not derived from GrammarType, the given value is used as the default value and the data type is derived from it. If it is None, the default value have to be set using expert parameter.

  • default (mixed) – Default value for the configuration option. Can accept callable (with option instance as an argument) - then the value will be determined at ‘runtime’ (possibly according to the other values of the section)

  • written_name (str) – Name of the configuration value in the input file

  • alternative_names (str or [str]) – Value can have an alternative name (that alternativelly denotes the value)

  • fixed_value (mixed) – If it is given, this option have a fixed_value value (provided by this parameter), that can not be changed by an user. #TODO - currently, callback (as in default_value) is not supported

  • required (bool) –

    Required option can not be set to None (however, a required one can be still be optional, if it has a default values). If required = None, it is set to True if both the conditions are met:

    • the value is not expert

    • the optional is not True and the option has not a default_value

  • init_by_default (bool) – If the value is not set, init it by default

  • result_is_visible (bool) –

    If True, the result (see the result property of Option) assigned to the option is visible if the value is get as its default value - in this mode the result can be used as a kind of default value, specific for given configuration object.

    If False, the result is visible to the user just using the result property and it should be some transformation of the value of the object (e.g. relative path of the given absolute path, id of assigned object etc.)

  • is_stored (bool) – If True, the value is readed/writed from the output file. If None, set to False if the value is Generated.

  • is_optional (bool or None) – If True, the value can be omited, if fixed order in the section is required None means True just if required is False (or it is determined to be False), see the required parameter.

  • is_hidden (bool) – The value is hidden from the user (no container.name access to the value).

  • is_expert (Union[bool,mixed]) – Expert values are somewhat hidden (e.g. listed at end) from the user. Expert values are not exported to the result, if they are set to the default value.

  • is_numbered_array (bool) – Such values can contains (sparse) arrays. In the resulting ouput, the members of the array are in the form NAME1=…, NAME2=…, … The default value for missing number can appear in the form NAME=…

  • is_repeated – If True, the real type of the Value is array of values of the given type. The name-value pair is repeated for each value of the array.

  • is_always_added (bool) – If False, add the value, only if its value is not the default value. Default None means False for expert values, True for the others.

  • name_in_grammar (bool or None) – The value in the conf file is prefixed by <name><name_value_delimiter> If None, the default type value (type.name_in_grammar) is used

  • name_format (str or None) – The way how the name is written

  • expert (Optional[mixed]) – If not None, set is_expert to True, default_value to the given value and required to False. Note, that also type can be determined from such given default_value.

  • write_alternative_name (bool) – Wheter use the name or the (first) alternative name in the output.

  • write_condition – If defined, write the value, only if write_condition(the option) is True.

  • condition

    If defined, the condition
    • the condition.parse_condition() is invoked, when given grammar element should be parsed. If it is False, the element is skipped

    • the condition() is invoked, when the elements of the container is listed to hide the inactive members

  • result_class – Redefine the class that holds data for this option/section

result_class

The values (or more precisely the objects holding the values) of SPR-KKR configuration should be of this class.

alias of ConfigurationValue

property _set_from_atoms

Allow to modify the result output value according to the computed atoms object.

The standard implementation of set_from_atoms relies on the underlying grammar type