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
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:
section (RepeatedConfigurationContainer)
proposed (RepeatedConfigurationContainer)
- _get_members(name, unknown, is_option, lower_case, *, accept)[source]
Return the repeated item selected by its index or key.
- Parameters:
name (Any)
unknown (Literal['find', 'add', 'ignore', 'fail'] | None)
is_option (bool | None)
lower_case (bool)
accept (Callable[[ase2sprkkr.common.configuration.Configuration], bool] | None)
- Return type:
- stage_clear(transaction, *, check_required=True)[source]
Stage an empty collection in
transaction.check_requiredis accepted for the common staged-clear protocol.- Parameters:
transaction (ase2sprkkr.common.configuration_transaction.ConfigurationTransaction)
check_required (bool)
- 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") andreport_invalid("raise","warn"or"ignore").valuessupplies the children, or one child name paired withvalue.unknowncontrols child assignment lookup andvalidation_reasonselects"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
valuesintransaction.unknowncontrols descendant assignment.mergeupdates the current collection instead of replacing it;kwargsare forwarded to descendant staging.- Parameters:
transaction (ase2sprkkr.common.configuration_transaction.ConfigurationTransaction)
values (Mapping[Any, Any] | Iterable[Any] | str | None)
value (Any)
unknown (Literal['find', 'add', 'ignore', 'fail'] | None)
merge (bool)
kwargs (Any)
- Return type:
bool
- _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)
- _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
- _abc_impl = <_abc._abc_data object>