Skip to content

Terminal output

terminal_output

Defines Rich / Typer helpers to display content in a terminal window

Used by the the kotobase CLI to display command outputs, like lookup information, and by the Build Pipeline to display upstream source download and database build progress

build_status(message)

Builds a themed rich.Status object from to display indeterminate progress

Used as a context manager to wrap database build step progress

Parameters:

Name Type Description Default
message str

The initial status message to display

required

Returns:

Type Description
Status

A rich.status.Status spinner bound to the themed console

download_progress_bar()

Builds a customized rich.Progress object to display network downloads

Used to show download progress for the kotobase databases and the upstream sources

inserted_rows_table(row_count_dict)

Creates a rich.Table to display how many rows have been inserted into the database for each table during a build

Parameters:

Name Type Description Default
row_count_dict dict[str, int]

Mapping of table names to their inserted row count

required

Returns: A themed rich.Table with the Table and Inserted Rows columns populated from row_count_dict

render_audio(key, clips)

Render the audio clips available for a key

Parameters:

Name Type Description Default
key str

The looked-up key

required
clips Sequence[AudioDTO]

The clips to list

required

render_audio_saved(paths)

Render the result of saving audio clips to disk

Parameters:

Name Type Description Default
paths Sequence[Path]

The written audio file paths

required

render_cache_cleared(removed, freed)

Render the result of clearing the cache

Parameters:

Name Type Description Default
removed Sequence[Path]

The paths that were removed

required
freed int

The number of bytes freed

required

render_cache_path(path)

Render the cache directory path

Parameters:

Name Type Description Default
path Path

The cache directory path

required

render_cache_size(sizes)

Render a breakdown of the cache disk usage

Parameters:

Name Type Description Default
sizes dict[str, int]

Title Cased label to byte count pairs

required

render_db_info(info)

Render database build metadata in a panel

Parameters:

Name Type Description Default
info dict[str, str]

The db_meta key and value pairs

required

render_entries(entries, *, query)

Render a list of dictionary entries in a panel

Parameters:

Name Type Description Default
entries Sequence[JMDictEntryDTO]

The entries to render

required
query str

The query, shown in the panel title

required

render_furigana(items)

Render furigana segmentations in a panel

Parameters:

Name Type Description Default
items Sequence[FuriganaDTO]

The furigana rows to render

required

render_jlpt_list(items, *, kind, level)

Render a full Tanos JLPT study list as a table

Parameters:

Name Type Description Default
items Sequence[Any]

The vocab, kanji or grammar items

required
kind str

One of vocab, kanji or grammar

required
level int

The JLPT level

required

render_kanji(kanji)

Render the full profile of a single kanji

Parameters:

Name Type Description Default
kanji KanjiDTO

The kanji profile to render

required

render_kanji_table(kanji, *, title)

Render a table of kanji search results

Parameters:

Name Type Description Default
kanji Sequence[KanjiDTO]

The matching kanji

required
title str

A Title Cased description of the search

required

render_lookup(result, *, with_names)

Render an aggregate word lookup as one panel of sub-sections

Parameters:

Name Type Description Default
result LookupResult

The aggregated lookup result

required
with_names bool

Whether to include the proper names section

required

render_names(names)

Render a list of proper names in a panel

Parameters:

Name Type Description Default
names Sequence[JMNeDictEntryDTO]

The names to render

required

render_no_results(query)

Print the shared empty result line

Parameters:

Name Type Description Default
query str

The query that returned nothing

required

render_radicals(radicals)

Render every search radical grouped by stroke count

Parameters:

Name Type Description Default
radicals Sequence[RadicalDTO]

The radicals to render

required

render_sentences(sentences, *, query)

Render example sentences in a panel

Parameters:

Name Type Description Default
sentences Sequence[SentenceDTO]

The sentences to render

required
query str

The query, used in the empty result message

required

render_word_jlpt(result)

Render the JLPT view for a word and its kanji

Parameters:

Name Type Description Default
result LookupResult

A lookup result carrying the JLPT data

required