ConfigurationRootDefinition

class ase2sprkkr.common.container_definitions.ConfigurationRootDefinition(name, members=[], **kwargs)[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

__init__(name, members=[], **kwargs)[source]

Definition of container (e.g. section of an input file). For the rest of the parameters see the RealItemDefinition.

Parameters:
  • has_hidden_members (bool) – If true, this section is not intended for a direct editing

  • is_repeated (bool or string) – The section can be repeated. The name of the section appears only once on the beginning (this differs from ValueDefinition.is_repeated #TODO - merge the meaning of the swtich). If a non-empty string is given, the values are divided by the string.

  • force_order (bool) – If True, the items has to retain the order, if False, the items can be in the input file in any order.

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.

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)[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]