Module refinery.lib.scripts.xlm.trace
The trace the emulator produces: one step per executed cell, with the status of the cell and the output level that decides which steps a trace shows.
Expand source code Browse git
"""
The trace the emulator produces: one step per executed cell, with the status of the cell and
the output level that decides which steps a trace shows.
"""
from __future__ import annotations
from enum import auto, Enum
from typing import Iterable, NamedTuple
from refinery.lib.scripts.xlm.commands import XlmSeverity
class XlmStatus(str, Enum):
"""
The state one executed cell left the program in.
"""
FullEvaluation = auto()
PartialEvaluation = auto()
Error = auto()
NotImplemented = auto()
End = auto()
Branching = auto()
FullBranching = auto()
Ignored = auto()
class XlmStep(NamedTuple):
"""
One executed cell of a run: the sheet it sits on with its one-based row and column, the
status the run left it in, the text the trace prints for it, its indentation inside a
branch, and the output level it prints at — the level of its command, or the lowest level
when the cell is no command call at all.
"""
sheet: str
row: int
col: int
status: XlmStatus
text: str
indent: int
severity: XlmSeverity
def visible_steps(steps: Iterable[XlmStep], level: int):
"""
The steps a trace at the given output level shows: a step the interpreter ignored never
shows, and otherwise a step shows when its own level reaches the requested one; a level
above the highest shows the steps of the highest.
"""
level = min(level, max(s.value for s in XlmSeverity))
for step in steps:
if step.status is XlmStatus.Ignored:
continue
elif step.severity.value >= level:
yield step
Functions
def visible_steps(steps, level)-
The steps a trace at the given output level shows: a step the interpreter ignored never shows, and otherwise a step shows when its own level reaches the requested one; a level above the highest shows the steps of the highest.
Expand source code Browse git
def visible_steps(steps: Iterable[XlmStep], level: int): """ The steps a trace at the given output level shows: a step the interpreter ignored never shows, and otherwise a step shows when its own level reaches the requested one; a level above the highest shows the steps of the highest. """ level = min(level, max(s.value for s in XlmSeverity)) for step in steps: if step.status is XlmStatus.Ignored: continue elif step.severity.value >= level: yield step
Classes
class XlmStatus (*args, **kwds)-
The state one executed cell left the program in.
Expand source code Browse git
class XlmStatus(str, Enum): """ The state one executed cell left the program in. """ FullEvaluation = auto() PartialEvaluation = auto() Error = auto() NotImplemented = auto() End = auto() Branching = auto() FullBranching = auto() Ignored = auto()Ancestors
- builtins.str
- enum.Enum
Class variables
var FullEvaluation-
The type of the None singleton.
var PartialEvaluation-
The type of the None singleton.
var Error-
The type of the None singleton.
var NotImplemented-
The type of the None singleton.
var End-
The type of the None singleton.
var Branching-
The type of the None singleton.
var FullBranching-
The type of the None singleton.
var Ignored-
The type of the None singleton.
class XlmStep (sheet, row, col, status, text, indent, severity)-
One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all.
Expand source code Browse git
class XlmStep(NamedTuple): """ One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all. """ sheet: str row: int col: int status: XlmStatus text: str indent: int severity: XlmSeverityAncestors
- builtins.tuple
Instance variables
var sheet-
Alias for field number 0
Expand source code Browse git
class XlmStep(NamedTuple): """ One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all. """ sheet: str row: int col: int status: XlmStatus text: str indent: int severity: XlmSeverity var row-
Alias for field number 1
Expand source code Browse git
class XlmStep(NamedTuple): """ One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all. """ sheet: str row: int col: int status: XlmStatus text: str indent: int severity: XlmSeverity var col-
Alias for field number 2
Expand source code Browse git
class XlmStep(NamedTuple): """ One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all. """ sheet: str row: int col: int status: XlmStatus text: str indent: int severity: XlmSeverity var status-
Alias for field number 3
Expand source code Browse git
class XlmStep(NamedTuple): """ One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all. """ sheet: str row: int col: int status: XlmStatus text: str indent: int severity: XlmSeverity var text-
Alias for field number 4
Expand source code Browse git
class XlmStep(NamedTuple): """ One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all. """ sheet: str row: int col: int status: XlmStatus text: str indent: int severity: XlmSeverity var indent-
Alias for field number 5
Expand source code Browse git
class XlmStep(NamedTuple): """ One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all. """ sheet: str row: int col: int status: XlmStatus text: str indent: int severity: XlmSeverity var severity-
Alias for field number 6
Expand source code Browse git
class XlmStep(NamedTuple): """ One executed cell of a run: the sheet it sits on with its one-based row and column, the status the run left it in, the text the trace prints for it, its indentation inside a branch, and the output level it prints at — the level of its command, or the lowest level when the cell is no command call at all. """ sheet: str row: int col: int status: XlmStatus text: str indent: int severity: XlmSeverity