animedex.render.tty
TTY renderer: human-friendly tables with explicit source markers.
The TTY path always shows the [src: <backend>] annotation per
plans/03 §5 because the human reader cannot inspect a JSON
_source field. render_for_stream() is the auto-switching
entry point used by the CLI: it picks render_tty() when the
destination is a terminal and the JSON renderer otherwise so
piped output remains parseable.
is_terminal
render_tty
- animedex.render.tty.render_tty(model: AnimedexModel, *, stream: Any = None) str[source]
Render a model into the human-friendly TTY form.
Dispatches on type:
Anime,Character,Staff,Studio,TraceHit, andTraceQuotaeach get a multi-line block. Other models fall back to a default representation that still carries the source marker.- Parameters:
model (AnimedexModel) – The
AnimedexModelinstance to render.stream (Any) – Optional destination stream used to pick terminal glyphs that the stream can encode.
- Returns:
The TTY-friendly string.
- Return type:
render_for_stream
- animedex.render.tty.render_for_stream(model: AnimedexModel, stream: Any) str[source]
Render the way the CLI does for a given stream.
When
streamis a TTY, returns the TTY-friendly output; otherwise returns source-attributed JSON. This is the single entry point CLI commands call so the “TTY vs pipe” decision lives in one place.- Parameters:
model (AnimedexModel) – The
AnimedexModelinstance to render.stream (Any) – Destination stream (typically
sys.stdout).
- Returns:
Rendered payload.
- Return type: