forte2.helpers.table#

Module Contents#

forte2.helpers.table.format_ansi(text: str, fg: str | None = None, bg: str | None = None, bold: bool = False, use_color: bool | None = None) str#

Return text formatted with optional ANSI color and bold styling.

Parameters:
textstr

The text to format.

fgstr, optional

Foreground color name (e.g., “red”, “bright_cyan”).

bgstr, optional

Background color name.

boldbool, optional

If True, apply bold styling.

use_colorbool, optional

Force color on/off. If None, auto-detect via sys.stdout.isatty().

Returns:
str

Formatted string with ANSI escape sequences if supported.

class forte2.helpers.table.AsciiTable(columns, formats=None, sep_major='=', sep_minor='-', padding=3, header_fg='bright_white', header_bg=None, bold_header=True, footer_fg='bright_white', footer_bg=None, row_fg='bright_white', row_bg=None, use_color=None)#
COLORS#
columns#
formats#
padding = '   '#
sep_major = '='#
sep_minor = '-'#
use_color#
header_fg = 'bright_white'#
header_bg = None#
footer_fg = 'bright_white'#
footer_bg = None#
row_fg = 'bright_white'#
row_bg = None#
bold_header = True#
col_widths = []#
total_width#
header() str#

Return a formatted, optionally colored and bold header section.

row(*values, fg=None, bg=None) str#

Return one formatted row, optionally colored.

footer() str#

Return a formatted footer line.