RepeatedConfigurationContainer

class ase2sprkkr.common.repeated_configuration_containers.RepeatedConfigurationContainer(definition, container=None)[source]

A container for configuration (problem-definition) options and/or sections.

Options in the configuration (problem-definition) files are grouped to sections, sections are then grouped in a configuration file object. This is a base class for these containers.

Class hierarchy

Inheritance diagram of ase2sprkkr.common.repeated_configuration_containers.RepeatedConfigurationContainer


Constructor

__init__(definition, container=None)[source]

Create the container and its members, according to the definition

class ContentsChange(section, proposed)[source]

Original structure of a staged repeated section.

Parameters:
commit()[source]
Return type:

None

rollback()[source]
Return type:

None

_add(id=None)[source]

Create one repeated item without applying public API restrictions.

add(id=None)[source]
_raw_items()[source]

Return physically stored items, independent of public collection views.

_raw_values()[source]

Return physically stored values, independent of public collection views.

_member_key(name)[source]

Convert a path component to an index or stored dictionary key.

_get_members(name, unknown, is_option, lower_case, *, accept)[source]

Return the repeated item selected by its index or key.

Parameters:
Return type:

Iterator[ase2sprkkr.common.configuration.Configuration]

stage_clear(transaction, *, check_required=True)[source]

Stage an empty collection in transaction.

check_required is accepted for the common staged-clear protocol.

Parameters:
Return type:

bool

get(name=None, unknown='find')[source]

Get the value, either of self or of a child of a given name.

Parameters:
  • name (None or str) – If None, return contained values as a dictionary. Otherwise, return the value of the member with a given name.

  • unknown (str or None) – If unknown == ‘find’ and there is no member with a given name, try to find the first such in descendant conainers.

Returns:

value

Return type:

mixed

set(values=None, value=None, *, unknown='find', validation_reason='set', retain_invalid=None, report_invalid=None, merge=False, **kwargs)[source]

Set repeated values and validate the complete proposal.

By default, replace the complete collection. With merge=True, append values to a list-like collection or update a dictionary-like collection by key.

Invalid-value retention and reporting are controlled independently by retain_invalid ("none", "typed" or "all") and report_invalid ("raise", "warn" or "ignore"). values supplies the children, or one child name paired with value. unknown controls child assignment lookup and validation_reason selects "set" or "parse" validation.

Parameters:
  • values (Mapping[Any, Any] | Iterable[Any] | str | None)

  • value (Any)

  • unknown (Literal['find', 'add', 'ignore', 'fail'] | None)

  • validation_reason (Literal['set', 'parse', 'save'])

  • retain_invalid (Literal['none', 'typed', 'all'] | None)

  • report_invalid (Literal['raise', 'warn', 'ignore'] | None)

  • merge (bool)

  • kwargs (Any)

Return type:

None

stage(transaction, values=None, value=None, *, unknown='find', merge=False, **kwargs)[source]

Stage repeated values in transaction.

unknown controls descendant assignment. merge updates the current collection instead of replacing it; kwargs are forwarded to descendant staging.

Parameters:
Return type:

bool

items()[source]
values()[source]
_as_dict(only_changed='basic', generated=False, copy=False)[source]

Return the content of the container as a dictionary. Nested containers will be transformed to dictionaries as well.

Parameters:
  • only_changed (bool | str)

  • generated (bool)

is_changed()[source]
_save_to_file(file, always=False, name_in_grammar=None, delimiter='')[source]

Save the content of the container to the file (according to the definition).

Return type:

bool

_validate(why)[source]

Validate the configuration data.

Parameters:

why (str)

has_any_value()[source]
Return type:

bool

values_of(name)[source]
_abc_impl = <_abc._abc_data object>