Switch
- class ase2sprkkr.common.configuration_definitions.Switch(item, values, condition=<function Switch.<lambda>>, name=None, template=None)[source]
Items of this class can control, which elements of grammar will be active and which not
Class hierarchy
Constructor
- __init__(item, values, condition=<function Switch.<lambda>>, name=None, template=None)[source]
- Parameters:
item – The name of Option, whose value determine the active elements
values –
Dictionary, with the possible values of the item in the keys and the active elements in the values.
example:
V('TYPE', Keyword('SCALAR', 'COMPLEX'), Switch( {'SCALAR' : V('SCALAR' : int), 'COMPLEX': V('COMPLEX', complex) }
desribes both the following files:
TYPE=SCALAR SCALAR=1
- and::
TYPE=COMPLEX COMPLEX=1e5 7e5
name – Not needed to be supplied, it can be autogenerated.
- create_object = None
- empty = Empty
- Parameters:
name (str | None)
- Return type:
ParserElement
- prepare_grammar(definition, grammar)[source]
Childs will have either the original grammar, or empty - set by _choose method. So replace the grammar by the forward.
- added_to_container(container)[source]
Hook called, when the object is assigned to the container (currently from the container constructor)
- property condition_name