Interpreter Module¶
Interpreter¶
-
class
TagScriptEngine.interpreter.Interpreter(blocks: List[TagScriptEngine.interface.block.Block])[source]¶ Bases:
objectThe TagScript interpreter.
-
process(message: str, seed_variables: Optional[Dict[str, TagScriptEngine.interface.adapter.Adapter]] = None, *, charlimit: Optional[int] = None, dot_parameter: bool = False, **kwargs) → TagScriptEngine.interpreter.Response[source]¶ Processes a given TagScript string.
- Parameters:
message (str) – A TagScript string to be processed.
seed_variables (Dict[str, Adapter]) – A dictionary containing strings to adapters to provide context variables for processing.
charlimit (int) – The maximum characters to process.
dot_parameter (bool) – Whether the parameter should be followed after a “.” or use the default of parantheses.
kwargs (Dict[str, Any]) – Additional keyword arguments that may be used by blocks during processing.
- Returns:
A response object containing the processed body, actions and variables.
- Return type:
- Raises:
TagScriptError – A block intentionally raised an exception, most likely due to invalid user input.
WorkloadExceededError – Signifies the interpreter reached the character limit, if one was provided.
ProcessError – An unexpected error occurred while processing blocks.
-
AsyncInterpreter¶
-
class
TagScriptEngine.interpreter.AsyncInterpreter(blocks: List[TagScriptEngine.interface.block.Block])[source]¶ Bases:
TagScriptEngine.interpreter.InterpreterAn asynchronous subclass of Interpreter that allows blocks to implement asynchronous methods. Synchronous blocks are still supported.
This subclass has no additional attributes from the Interpreter class. See Interpreter for full documentation.
-
async
process(message: str, seed_variables: Optional[Dict[str, TagScriptEngine.interface.adapter.Adapter]] = None, *, charlimit: Optional[int] = None, dot_parameter: bool = False, **kwargs) → TagScriptEngine.interpreter.Response[source]¶ Asynchronously process a given TagScript string.
This method has no additional attributes from the Interpreter class. See
Interpreter.processfor full documentation.
-
async
Context¶
-
class
TagScriptEngine.interpreter.Context(verb: TagScriptEngine.verb.Verb, res: TagScriptEngine.interpreter.Response, interpreter: TagScriptEngine.interpreter.Interpreter, og: str)[source]¶ Bases:
objectAn object containing data on the TagScript block processed by the interpreter. This class is passed to adapters and blocks during processing.
-
interpreter¶ The interpreter processing the TagScript.
- Type:
-
Response¶
-
class
TagScriptEngine.interpreter.Response(*, variables: Optional[Dict[str, TagScriptEngine.interface.adapter.Adapter]] = None, extra_kwargs: Optional[Dict[str, Any]] = None)[source]¶ Bases:
objectAn object containing information on a completed TagScript process.
-
actions¶ A dictionary that blocks can access and modify to define post-processing actions.
- Type:
Dict[str, Any]
-
variables¶ A dictionary of variables that blocks such as the
LooseVariableGetterBlockcan access.
-
Node¶
-
class
TagScriptEngine.interpreter.Node(coordinates: Tuple[int, int], verb: Optional[TagScriptEngine.verb.Verb] = None)[source]¶ Bases:
objectA low-level object representing a bracketed block.
build_node_tree¶
-
TagScriptEngine.interpreter.build_node_tree(message: str) → List[TagScriptEngine.interpreter.Node][source]¶ Function that finds all possible nodes in a string.
- Returns:
A list of all possible text bracket blocks.
- Return type:
List[Node]