ConfigurationRootDefinition

class ase2sprkkr.common.container_definitions.ConfigurationRootDefinition(name, members=[], written_name=None, info=None, description=None, is_optional=None, is_hidden=False, is_expert=False, experimental=False, has_hidden_members=False, name_in_grammar=None, force_order=None, name_regex=False, result_class=None, is_repeated=False, repeated_delimiter=None, repeated_count=None, repeated_with_name=False, write_condition=None, warning_condition=None, validators=())[source]

From this class, the definition of the format of a whole configuration file should be derived.

Class hierarchy

Inheritance diagram of ase2sprkkr.common.container_definitions.ConfigurationRootDefinition


Constructor

Parameters:

validators (Callable[[Any, Any, str], Any] | Iterable[Callable[[Any, Any, str], Any]] | None)

__init__(name, members=[], written_name=None, info=None, description=None, is_optional=None, is_hidden=False, is_expert=False, experimental=False, has_hidden_members=False, name_in_grammar=None, force_order=None, name_regex=False, result_class=None, is_repeated=False, repeated_delimiter=None, repeated_count=None, repeated_with_name=False, write_condition=None, warning_condition=None, validators=())[source]
Parameters:

validators (Callable[[Any, Any, str], Any] | Iterable[Callable[[Any, Any, str], Any]] | None)

write_last_delimiter = False

Do not print additional newline after the last section

name_in_grammar = False

The configuration files has commonly no “name” of its content, they just contains their content.

However, in some cases the name_in_grammar could be used for some kind of prefix in the file, however, it is better to use a fixed value for this purpose.

item_type = 'configuration'
classmethod definition_from_dict(name, defs=None)[source]

Create instance of the definition from a dictionary, creating the sections (and values) definitions recursively.

property sections
custom_value_name = 'CUSTOM_SECTION'

Just the name that appears in the grammar, when it is printed.

_tuple_with_my_name(expr, delimiter=None)[source]

Do not create tuple (name, value) for the root class.

parse_return(val, return_value_only=True)[source]

Clean up the parsed values (unpack then from unnecessary containers)

There is no name in the parsed results (see how ConfigurationRootDefinition._tuple_with_my_name is redefined).

_create_grammar(allow_dangerous=False, *, allow_incomplete=False)[source]

Returns the grammar to parse the configuration file.

This method just tweaks the grammar (generated by the common container implementation) to ignore comments, so the comments would be ignored just once.

add_ignored(grammar)[source]
_generic_info()[source]