soleil.overrides.variable_path#
Module Attributes
A reference string such as |
Functions
|
Returns a |
Classes
|
|
|
|
|
|
|
Contains a sequence of references relative to the root configuration that point to a variable. |
- soleil.overrides.variable_path.CompoundRefStr#
A reference string such as
'a[0].b.c[0]'that can be converted to aVarPath
- class soleil.overrides.variable_path.Ref#
Bases:
ABC
- class soleil.overrides.variable_path.Subscript(value: Any = <class 'soleil._utils.Unassigned'>)#
Bases:
Ref
- class soleil.overrides.variable_path.VarPath(initlist=None)#
Bases:
UserListContains a sequence of references relative to the root configuration that point to a variable.
Warning
The
get_*methods will only work once all the modules nested in the root config and have been loaded – i.e., after the root config is loaded. In practice, this means that they should only be called as part of member resolution.- append(entry)#
S.append(value) – append value to the end of the sequence
- get(obj=<class 'soleil._utils.Unassigned'>)#
Applies the get methods of a a sequence of refs to the root config or the specified object
- get_module(obj=<class 'soleil._utils.Unassigned'>)#
Returns the module containing the variable where the variable path points to
- get_modifiers(obj=<class 'soleil._utils.Unassigned'>)#
Returns the explicit modifiers for the referenced variable or
Noneif none are specified
- get_with_container(obj=<class 'soleil._utils.Unassigned'>)#
Returns a tuple with the referenced object and its container (either a class or a solconf object) of the variable pointed to by the path. If the path points to the root, then
Noneis returned. Note that the parent of a promoted member is its solconf module (promoted members can only exist at the global level within a solconf module).
- soleil.overrides.variable_path.deduce_soleil_var_path(target_name: str, frame: frame | int | None = 0, relative=False) VarPath | None#
Returns a
VarPathspecifying how to access a variable namedtarget_namedefined in the specified frame relative to the root configuration. Will returnNoneif the variable is not visible (e.g., it is promoted, and hence its name is not accessible)- Parameters:
target_name – The name of the variable whose name is being deduced.
frame – The frame where the variable named
target_nameis being defined – by default assumed to be the the parent frame of the caller, sincededuce_soleil_var_pathis usually called within_soleil_overrides().relative – Whether to return a variable path relative to the containing module. By default, an absoulte var path is returned that is relative to the root config.
Example:
# main.solconf assert __soleil_var_path__ == VarPath() # Is True (this is the root config) a = load('module2') # Will propagate 'a' as the module's __soleil_var_path__ # module2.solconf assert __soleil_var_path__ == 'a' # Is True b = 1 deduce_soleil_var_path('b', -1) == 'a.b' # Is True, -1 bc usuallly called within a function `fxn` such as override() or load()