soleil.overrides.parser#
Functions
|
|
|
Takes code containing one or more assignment such as |
|
Takes a reference such as |
Classes
|
Contains a parsed override and components. |
Splits python code containing one or more assignments into overrides, enforcing override syntax restrictions |
|
|
An enumeration. |
|
Parses a reference string, raising an error on invalid strings. |
Checks that a specified value expression is valid |
- class soleil.overrides.parser.OverrideType(value)#
Bases:
EnumAn enumeration.
- existing = 0#
Override an existing value
- class soleil.overrides.parser.Override(target: VarPath, assign_type: OverrideType, value_expr: Expression, source: str | None = None, used: int = 0)#
Bases:
objectContains a parsed override and components.
- source: str | None = None#
The source code corresponding to this override, if available
- used: int = 0#
The number of times the override has been used – can be used multiple times when overrides are shared by a spawned parent class and its child class
- get_value(_globals=None, _locals=None)#
Extracts the assignment value from the specified globals and locals.
- class soleil.overrides.parser.RefExtractor(*args, **kwargs)#
Bases:
_RestrictedNodeVisitorParses a reference string, raising an error on invalid strings.
Builds a list of references.
- default_nodes: Tuple[Type[AST], ...] = (<class '_ast.Expr'>, <class '_ast.Module'>, <class '_ast.Index'>, <class '_ast.Load'>, <class '_ast.Store'>)#
Will call
ast.NodeVisitor.generic_visiton these nodes
- specialized_nodes: Tuple[Type[AST], ...] = (<class '_ast.Attribute'>, <class '_ast.Subscript'>, <class '_ast.Constant'>, <class '_ast.Name'>)#
A specialized method is implemented for these nodes
- class soleil.overrides.parser.ValueVerifier#
Bases:
_RestrictedNodeVisitorChecks that a specified value expression is valid
- default_nodes: Tuple[Type[AST], ...] = (<class '_ast.Constant'>, <class '_ast.Name'>, <class '_ast.Attribute'>, <class '_ast.Subscript'>, <class '_ast.BinOp'>, <class '_ast.operator'>, <class '_ast.Tuple'>, <class '_ast.List'>, <class '_ast.Load'>, <class '_ast.UnaryOp'>, <class '_ast.USub'>)#
Will call
ast.NodeVisitor.generic_visiton these nodes
- specialized_nodes: Tuple[Type[AST], ...] = ()#
A specialized method is implemented for these nodes
- class soleil.overrides.parser.OverrideSplitter#
Bases:
_RestrictedNodeVisitorSplits python code containing one or more assignments into overrides, enforcing override syntax restrictions
- specialized_nodes: Tuple[Type[AST], ...] = (<class '_ast.Assign'>,)#
A specialized method is implemented for these nodes
- soleil.overrides.parser.parse_ref(ref: str)#
Takes a reference such as
'a.b[0].xand parses it into a sequence of attribute or item references.