MCPcopy
hub / github.com/mitmproxy/mitmproxy / format_message_flow

Function format_message_flow

mitmproxy/tools/console/common.py:597–649  ·  view source on GitHub ↗
(
    *,
    render_mode: RenderMode,
    focused: bool,
    timestamp_start: float,
    marked: str,
    protocol: str,
    client_address,
    server_address,
    total_size: int,
    duration: float | None,
    error_message: str | None,
)

Source from the content-addressed store, hash-verified

595
596@lru_cache(maxsize=800)
597def format_message_flow(
598 *,
599 render_mode: RenderMode,
600 focused: bool,
601 timestamp_start: float,
602 marked: str,
603 protocol: str,
604 client_address,
605 server_address,
606 total_size: int,
607 duration: float | None,
608 error_message: str | None,
609):
610 conn = f"{human.format_address(client_address)} <-> {human.format_address(server_address)}"
611
612 items = []
613
614 if render_mode in (RenderMode.TABLE, RenderMode.DETAILVIEW):
615 items.append(
616 format_left_indicators(
617 focused=focused, intercepted=False, timestamp=timestamp_start
618 )
619 )
620 else:
621 if focused:
622 items.append(fcol(">>", "focus"))
623 else:
624 items.append(fcol(" ", "focus"))
625
626 if render_mode is RenderMode.TABLE:
627 items.append(fcol(fixlen(protocol.upper(), 5), SCHEME_STYLES[protocol]))
628 else:
629 items.append(fcol(protocol.upper(), SCHEME_STYLES[protocol]))
630
631 items.append(("weight", 1.0, truncated_plain(conn, "text", "left")))
632 if error_message:
633 items.append(("weight", 1.0, truncated_plain(error_message, "error", "left")))
634
635 if total_size:
636 size, size_style = format_size(total_size)
637 items.append(fcol(fixlen_r(size, 5), size_style))
638 else:
639 items.append(("fixed", 5, urwid.Text("")))
640
641 if duration:
642 duration_pretty, duration_style = format_duration(duration)
643 items.append(fcol(fixlen_r(duration_pretty, 5), duration_style))
644 else:
645 items.append(("fixed", 5, urwid.Text("")))
646
647 items.append(format_right_indicators(replay=False, marked=marked))
648
649 return urwid.Pile([urwid.Columns(items, dividechars=1, min_width=15)])
650
651
652@lru_cache(maxsize=800)

Callers 1

format_flowFunction · 0.85

Calls 9

format_left_indicatorsFunction · 0.85
fcolFunction · 0.85
fixlenFunction · 0.85
truncated_plainFunction · 0.85
format_sizeFunction · 0.85
fixlen_rFunction · 0.85
format_durationFunction · 0.85
format_right_indicatorsFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…