soleil.overrides.overrides#

Module Attributes

OverrideSpec

An override specification -- Various possibilities:

Functions

cast_overrides(overrides)

Takes strings with one or more overrides, dictionaries with refs and values (e.g., {'a.b[0].x':3}) or Override objects obtained from parse_overrides() and converts them to a list of Override objects.

eval_overrides(overrides[, globals_, ...])

Computes the value of all input overrides and returns overrides in pre-computed form.

merge_overrides(overrides, new_overrides)

Takes a given set of overrides and updates them with a new set of overrides.

Classes

PreCompOverride(target, assign_type, value_expr)

An Override with a pre-computed value.

soleil.overrides.overrides.OverrideSpec#

An override specification – Various possibilities:

# As a string
'a[0].b = 3'

# As a multi-line or semicolon-separated string
"""
a[0].b = 3; x.y = 4
var.sub = a[0].b
"""

# As a dictionary
{'a[0].b': 3, 'x.y':4, 'var.sub':a[0].b

# As an Override object
overrides = parse_overrides('a[0].b=3')[0]

alias of Union[str, Dict[str, Any], Override]

class soleil.overrides.overrides.PreCompOverride(target: VarPath, assign_type: OverrideType, value_expr: Expression, source: str | None = None, used: int = 0)#

Bases: Override

An Override with a pre-computed value.

get_value(*args, **kwargs)#

Extracts the assignment value from the specified globals and locals.

soleil.overrides.overrides.cast_overrides(overrides: List[str | Dict[str, Any] | Override]) List[Override]#

Takes strings with one or more overrides, dictionaries with refs and values (e.g., {‘a.b[0].x’:3}) or Override objects obtained from parse_overrides() and converts them to a list of Override objects.

The output list can contain more elements than the input since both str and dict override specifiers can contain multiple overrides.

soleil.overrides.overrides.eval_overrides(overrides: str | Dict[str, Any] | Override | List[str | Dict[str, Any] | Override], globals_=None, locals_=None, check_unique=True) List[PreCompOverride]#

Computes the value of all input overrides and returns overrides in pre-computed form. If an entry is already an override in pre-computed form, that same object is returned for that entry.

soleil.overrides.overrides.merge_overrides(overrides: List[str | Dict[str, Any] | Override], new_overrides: List[str | Dict[str, Any] | Override])#

Takes a given set of overrides and updates them with a new set of overrides.