TerminalPrinter#

class montreal_forced_aligner.helper.TerminalPrinter(print_function=None)[source]#

Bases: object

Helper class to output colorized text

Parameters:

print_function (Callable, optional) – Function to print information, defaults to print

Variables:

colors (dict[str, str]) – Mapping of color names to terminal codes in colorama (or empty strings if the global terminal_colors flag is set to False)

colorize(text, color)[source]#

Colorize a string

Parameters:
  • text (Any) – Text to colorize

  • color (str) – Colorama code or empty string to wrap the text

Returns:

Colorized string

Return type:

str

emphasized_text(text)[source]#

Highlight text as emphasis

Parameters:

text (Any) – Text to highlight

Returns:

Highlighted text

Return type:

str

error_text(text)[source]#

Highlight text as an error

Parameters:

text (Any) – Text to highlight

Returns:

Highlighted text

Return type:

str

format_info_lines(lines)[source]#

Format lines

Parameters:

lines (Union[list[str], str) – Lines to format

Returns:

Formatted string

Return type:

str

property indent_string#

Indent string to use in formatting the output messages

pass_text(text)[source]#

Highlight text as good

Parameters:

text (Any) – Text to highlight

Returns:

Highlighted text

Return type:

str

print_block(block, starting_level=1)[source]#

Print a configuration block

Parameters:
  • block (dict) – Configuration options to output

  • starting_level (int) – Starting indentation level

print_config(configuration)[source]#

Pretty print a configuration

Parameters:

configuration (dict[str, Any]) – Configuration to print

print_end_section()[source]#

Mark the end of a section

print_green_stat(stat, text)[source]#

Print a statistic in green

Parameters:
  • stat (Any) – Statistic to print

  • text (str) – Other text to follow statistic

print_header(header)[source]#

Print a section header

Parameters:

header (str) – Section header string

print_info_lines(lines)[source]#

Print formatted information lines

Parameters:

lines (Union[list[str], str) – Lines to format

print_information_line(key, value, key_color=None, value_color=None, level=1)[source]#

Pretty print a given configuration line

Parameters:
  • key (str) – Configuration key

  • value (Any) – Configuration value

  • key_color (str) – Key color

  • value_color (str) – Value color

  • level (int) – Indentation level

print_red_stat(stat, text)[source]#

Print a statistic in red

Parameters:
  • stat (Any) – Statistic to print

  • text (str) – Other text to follow statistic

print_sub_header(header)[source]#

Print a subsection header

Parameters:

header (str) – Subsection header string

print_yellow_stat(stat, text)[source]#

Print a statistic in yellow

Parameters:
  • stat (Any) – Statistic to print

  • text (str) – Other text to follow statistic

warning_text(text)[source]#

Highlight text as a warning

Parameters:

text (Any) – Text to highlight

Returns:

Highlighted text

Return type:

str