BaseDefinition
- class ase2sprkkr.common.configuration_definitions.BaseDefinition(name, alternative_names=None, is_optional=False, is_hidden=False, is_expert=False, name_in_grammar=None, info=None, description=None, write_alternative_name=False, result_class=None)[source]
A base class for a configuration definition, either of an option, or of a container. The definition determine the type of value(s) in the configuration/problem-definition file, the format of the values, the way how it/they is/are read etc…
Class hierarchy
Constructor
- Parameters
write_alternative_name (bool) –
- __init__(name, alternative_names=None, is_optional=False, is_hidden=False, is_expert=False, name_in_grammar=None, info=None, description=None, write_alternative_name=False, result_class=None)[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 (bool) – 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
The name of the option/section
- alternative_names
Alternative names of the option/section. The option/section can be “denoted” in the configuration file by either by its name or any of the alternative names.
Is it required part of configuration (or can it be ommited)?
- name_in_grammar = True
Is the name of the value/section present in the file?
When False, the option/section name is not written to the file at all. The value(s) of the option/section is/are then expected to be located in the file just after the previous one.
By default, all options and sections… are named (in the configuration file). However, the attribute can be redefined in instantiated objects and/or descendant classes to change the behavior.
- _info
A short help text describing the content for the users.
- _description
A longer help text describing the content for the users.
- result_class = None
Parsing of the data results in an instance of this class. To be redefined in descendants.
- info(generic=True)[source]
Return short help string.
- Parameters
generic (bool) – If the definition has no help specified and generic is True, return a (not saying much) generic help string
- Return type
str
- grammar(allow_dangerous=False)[source]
Generate grammar with the correct settings of pyparsing global state
- Parameters
allow_dangerous (bool) – Allow dangerous values - i.e. values that do not fulfill the requirements for the given-option value (i.e. a type requirement or other constraints).
- _description_indentation = ' '
Nested levels of description will be indented using this ‘prefix’
- description(verbose=True, show_hidden=False, prefix='')[source]
- Parameters
verbose (bool) – If true, add also detailed documentation of all included items (e.g. members of a container)
show_hidden (bool) – If
False
(default), do not show descriptions of hidden members.prefix (str) – The string, with with each line will begin (commonly the spaces for the indentation).
- _tuple_with_my_name(expr, delimiter=None, has_value=True, is_numbered_array=False)[source]
Create the grammar returning tuple (self.name, <result of the expr>)
- Parameters
expr – Pyparsing expresion for the value of the option/section
delimiter – Pyparsing expression for the name-value delimiter
has_value (bool) – If False, do not add the parsed value to the results. This can be used e.g. for separators (see
ase2sprkkr.common.grammar_types.Separator
) etc.is_numbered_array (bool) – If True, the resulting grammar is in the form NAME[index]=….
- do_not_skip_whitespaces_before_name = False
- _get_copy_args()[source]
Compute the dictionary that defines the attributes to create a copy of this object.
- Returns
copy – The returning dictionary has this structure: { name of the argument of the __init__ function : name of the object attribute }
- Return type
Dict
- _copy_excluded_args = ['expert']