Exemplo n.º 1
0
def _serialize_variables(variables):

    hidden = variables.get("__traceback_hidden_variables__", ())

    if hidden is True:
        return

    if not isinstance(hidden, (tuple, list)):
        hidden = ()

    variables = tuple((safe_force_text(key), safe_force_text(value))
                      for key, value in variables.items() if not key in hidden)

    if variables:
        yield wl.OpenerView([
            "Local variables",
            wl.Grid(
                iterate((("Key", "Value"), ), variables),
                Background=[None, [wl.LightGray]],
                Alignment=wl.Left,
                Frame=wl.LightGray,
            ),
        ])
    else:
        yield "No local variables"
Exemplo n.º 2
0
def serialize_traceback(exc_type, exc_value, tb, **opts):
    return wl.OpenerView([
        wl.Row([
            safe_force_text(exc_type.__name__), " ",
            safe_force_text(exc_value)
        ]),
        wl.Style(
            wl.Column(_serialize_traceback(exc_type, exc_value, tb, **opts)),
            FontFamily="Courier")
    ], True)
Exemplo n.º 3
0
def _serialize_frames(filename,
                      function,
                      pre_context,
                      post_context,
                      context_line,
                      variables,
                      lineno,
                      pre_context_lineno,
                      is_opened=False,
                      **opts):

    if filename:
        description = wl.Row([
            wl.Button(
                wl.Style(filename,
                         wl.RGBColor(0.25, 0.48, 1),
                         wl.Small,
                         FontFamily="Courier"),
                wl.If(wl.FileExistsQ(filename), wl.SystemOpen(filename)),
                Appearance="Frameless",
            ),
            " in ",
            function,
        ])
    else:
        description = function

    yield wl.OpenerView(
        [
            description,
            wl.Column(
                iterate(
                    (wl.Column(
                        iterate(
                            (_paginate(pre_context_lineno + i, l)
                             for i, l in enumerate(pre_context)),
                            [
                                wl.Item(
                                    _paginate(lineno, context_line),
                                    Background=wl.LightYellow,
                                )
                            ],
                            (_paginate(lineno + i + 1, l)
                             for i, l in enumerate(post_context)),
                        ),
                        Background=[[wl.GrayLevel(0.95),
                                     wl.GrayLevel(1)]],
                        Frame=wl.LightGray,
                    ), ),
                    _serialize_variables(variables),
                )),
        ],
        is_opened,
    )