Skip to content

error

Classes:

CustomInlineExprError

Bases: CustomRuntimeError

Thrown when a InlineExpr error occurs.

Methods:

  • add_stack_infos

    Adds additional informations on the expr vars used within the with statement of a InlineExprWrapper.

add_stack_infos

add_stack_infos(expr_vars: dict[str, Any], ie: InlineExprWrapper) -> None

Adds additional informations on the expr vars used within the with statement of a InlineExprWrapper.

Parameters:

  • expr_vars

    (dict[str, Any]) –

    Dictionary containing the current scope's local expr variables.

  • ie

    (InlineExprWrapper) –

    The InlineExprWrapper instance.

Source code in vsexprtools/inline/error.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def add_stack_infos(self, expr_vars: dict[str, Any], ie: InlineExprWrapper) -> None:
    """
    Adds additional informations on the expr vars used within the with statement of a InlineExprWrapper.

    Args:
        expr_vars: Dictionary containing the current scope's local expr variables.
        ie: The InlineExprWrapper instance.
    """
    from .helpers import ComputedVar
    from .manager import InlineExprWrapper

    self.add_note(_color_tag("\nInlineExpr stack infos:", "\033[0;33m"))

    def _format_var_per_plane(v: ComputedVar) -> str:
        return ("\n    " + (" " * (len(k) + 2))).join(v.to_str_per_plane(ie._format.num_planes))

    for k, v in sorted(expr_vars.items()):
        if k.startswith("_"):
            continue

        if isinstance(v, InlineExprWrapper):
            k = f"{k}.out"
            v = _format_var_per_plane(v.out)
        elif isinstance(v, ComputedVar):
            v = _format_var_per_plane(v)
        elif v is not None:
            with suppress(TypeError):
                v = str([str(x) for x in iter(v)])

        self.add_note("    " + _color_tag(f"{k}: ", "\033[1;37m") + str(v))