ContainerDefinition

class ase2sprkkr.common.configuration_definitions.ContainerDefinition(name, members=[], alternative_names=[], info=None, description=None, is_optional=False, is_hidden=False, is_expert=False, has_hidden_members=False, name_in_grammar=None, force_order=None, write_alternative_name=False, result_class=None)[source]

Base class for a definition (of contained data, format, etc) of either a whole configuration file (e.g. InputParameters or e.g. Potential) or its Section.

Class hierarchy

Inheritance diagram of ase2sprkkr.common.configuration_definitions.ContainerDefinition

Constructor

Parameters

write_alternative_name (bool) –

__init__(name, members=[], alternative_names=[], info=None, description=None, is_optional=False, is_hidden=False, is_expert=False, has_hidden_members=False, name_in_grammar=None, force_order=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

value_name_format = None

The (print) format, how the name is written

static _dict_from_named_values(args, items=None)[source]

auxiliary method that creates dictionary from the arguments

force_order = False

Force order of its members

configuration_type_name = 'SECTION'

Name of the container type in the runtime documentation

data_description(verbose=False, show_hidden=False, prefix='')[source]

Return the runtime documentation for the configuration described by this object.

Parameters
  • verbose (Union[bool, str, int]) – If False, only one line with the section name and basic info is returned. If True, the items contained in the section are listed. If 'all', add also detailed info about all descendants. If an int is given, print detailed informations about n levels. I.e. 1 is the same as True

  • show_hidden (bool) – If False, do not show hidden members.

  • prefix (str) – The string, with with each line will begin (commonly the spaces for the indentation).

additional_data_description(verbose=False, show_hidden=False, prefix='')[source]

Return the description (documentation for runtime) of the items in the container.

Parameters
  • verbose (Union[bool, str, int]) – If True, include detailed description of the children. If 'all', include even detailed description. If int is given, print detailed informations up to n levels.

  • show_hidden – If False, do not show hidden members.

  • prefix (str) – The string, with with each line will begin (commonly the spaces for the indentation).

members()[source]
names()[source]
remove(name)[source]
copy(args=[], items=[], remove=[], defaults={}, **kwargs)[source]

Copy the section with the contained values modified by the arguments.

create_object(container=None)[source]

Creates Section/Option/…. object (whose properties I define)

all_member_names()[source]
_values_grammar(allow_dangerous=False, delimiter=None)[source]
Parameters

allow_dangerous (bool) –

_grammar(allow_dangerous=False)[source]
classmethod delimited_custom_value_grammar()[source]

Return the grammar for the custom child with delimiter. The delimiter can delimite it either from the previous child or from the section name.

custom_name_characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-()'

Which characters can appears in an unknown child (value/section) name

classmethod custom_member_grammar(value_names=[])[source]

Grammar for the custom - unknown - child

_first_section_has_to_be_first()[source]

Has/ve the first child(s) in an unordered sequence fixed position?

parse_file(file, return_value_only=True, allow_dangerous=False)[source]

Parse the file, return the parsed data as dictionary

parse(string, whole_string=True, return_value_only=True, allow_dangerous=False)[source]

Parse the string, return the parsed data as dictionary

parse_return(val, return_value_only=True)[source]

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

Parameters

return_value_only (bool) – Return only value, not name - value tuple

async parse_from_stream(stream, up_to, start=None, whole_string=True, return_value_only=True, allow_dangerous=False)[source]

Parse string readed from asyncio stream. The stream is readed up to the given delimiter

read_from_file(file, allow_dangerous=False, **kwargs)[source]

Read a configuration file and return the parsed Configuration object

validate(container, why='save')[source]

A function for validation of just the parsed result (not the user input)

Parameters

why (str) –