ConsoleTable

class tfsnippet.utils.ConsoleTable(col_count, col_space=3, col_align=None, expand_col=0)

Bases: object

A class to help format a console table.

Methods Summary

add_config(config[, sort_keys]) Add a config to the table.
add_dict(key_values[, sort_keys]) Add a key-value sequence to the table.
add_hr([c]) Add a horizon line.
add_key_values(key_values[, sort_keys]) Add a key-value sequence to the table.
add_row(columns) Add a row with full columns.
add_skip() Add an empty row.
add_title(title[, top_right]) Add row of title.
format() Format the table to string.

Methods Documentation

add_config(config, sort_keys=False)

Add a config to the table.

Parameters:
  • config (Config) – A config object.
  • sort_keys (bool) – Whether or not to sort the keys?
add_dict(key_values, sort_keys=False)

Add a key-value sequence to the table.

Parameters:
  • key_values – Dict, or key-value sequence.
  • sort_keys (bool) – Whether or not to sort the keys?
add_hr(c='-')

Add a horizon line.

Parameters:c (str) – The character of the horizon line.
add_key_values(key_values, sort_keys=False)

Add a key-value sequence to the table.

Parameters:
  • key_values – Dict, or key-value sequence.
  • sort_keys (bool) – Whether or not to sort the keys?
add_row(columns)

Add a row with full columns.

Parameters:columns (Iterable[str]) – The column contents.
add_skip()

Add an empty row.

add_title(title, top_right=None)

Add row of title.

Parameters:
  • title (str) – The title content.
  • top_right (str) – Optional top-right content.
format()

Format the table to string.

Returns:The formatted table.
Return type:str