ConfigurationRootDefinition

class ase2sprkkr.common.configuration_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.configuration_definitions.ConfigurationRootDefinition

Constructor

__init__(name, members=[], **kwargs)[source]
Parameters
  • name (str) – Name of the value/section

  • alternative_names (str or [str]) – Alternative names that can denotes the value

  • is_optional (boolean) – If True, this section/value can be missing in the .pot/task file

  • is_hidden (boolean) – Hidden values are not offered to a user, usually they are set by another object (and so a direct setting of their values has no sense)

  • is_expert (boolean) – Expert values/sections are not required and they are somewhat hidden from the user

  • name_in_grammar (boolean or None) – If False, there the name of the variable is not printed in the configuration file. The variable is recognized by its position. If None, the default class value is used

  • info (str) – A short help message for the value/section. It will be the perex for description.

  • description (str) – The additional informations for the users.

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

  • result_class – Redefine the class that holds data for this option/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 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).

_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.