zabgrab.ui.listing

Laying out listings of data points (zabgrab show) as lines of text.

Listings can be long, so they’re plain aligned columns rather than rich tables: quick to produce, and readable in a pager, a pipe or a file.

Module Attributes

Line

"", "bold" or "dim".

NEWLINE

What newlines in a text value become when it's kept to one line.

GAP

Space between columns.

Functions

histogram_lines(histograms, bins)

Lay out bin counts: a section per item, with a line per bin.

label(series)

Name a series' item, with its units and resolution if it has them.

listing_lines(sections, tz, *, headings[, ...])

Lay out a listing.

zabgrab.ui.listing.Line

"", "bold" or "dim".

Type:

A line of output and its style

alias of tuple[str, str]

zabgrab.ui.listing.NEWLINE = ' ⏎ '

What newlines in a text value become when it’s kept to one line.

zabgrab.ui.listing.GAP = '  '

Space between columns.

zabgrab.ui.listing.label(series)[source]

Name a series’ item, with its units and resolution if it has them.

Parameters:

series (Series)

Return type:

str

zabgrab.ui.listing.listing_lines(sections, tz, *, headings, offset=0, wrap=False)[source]

Lay out a listing.

Parameters:
  • sections (sequence of Section) – The listing (see zabgrab.services.listing.listing()).

  • tz (tzinfo or None) – The time zone to show times in (None for local time).

  • headings (bool) – Head each section with its item and how many of its points are shown (for listings with a section per item).

  • offset (int, optional) – How many points were skipped at the start of each section, for the headings’ counts.

  • wrap (bool, optional) – Show text values in full, over several lines, rather than on one line with ⏎ for each line break.

Returns:

list of Line – The lines, without line breaks, and how to style each.

Return type:

list[tuple[str, str]]

zabgrab.ui.listing.histogram_lines(histograms, bins)[source]

Lay out bin counts: a section per item, with a line per bin.

Parameters:
Returns:

list of Line – The lines, without line breaks, and how to style each.

Return type:

list[tuple[str, str]]