tabulardelta.formatters.overview_row_formatter module
- class tabulardelta.formatters.overview_row_formatter.Content(state_char: str = '', name: str = '', rows: int = 0, equal_rows: int = 0, unequal_rows: int = 0, added_rows: int = 0, removed_rows: int = 0, unknown_rows: int = 0, cols: int = 0, added_cols: int = 0, removed_cols: int = 0, value_changed_cols: int = 0, name_changed_cols: int = 0, type_changed_cols: int = 0)[source]
Bases:
Row
Row with comparison data added by
OverviewRowFormatter.format()
orOverviewRowFormatter.add_row()
.Methods
get_cells() -> list[Cell | str]:
Retrieve cells from the row
- added_cols: int = 0
Number of added columns (not in old table).
- added_rows: int = 0
Number of added rows (not in old table).
- cols: int = 0
Number of columns in the new table.
- equal_rows: int = 0
Number of matched and equal rows.
- get_cells() list[Cell | str] [source]
Retrieve cells from the row.
- Returns
list[Cell | str]
: Returns cells such that they can be casted using
tabulartext.Table.from_lists()
.
- Returns
- name: str = ''
Name of the table.
- name_changed_cols: int = 0
Number of columns with changed names.
- removed_cols: int = 0
Number of removed columns (not in new table).
- removed_rows: int = 0
Number of removed rows (not in new table).
- rows: int = 0
Number of rows in the new table.
- state_char: str = ''
One-char summary of comparison.
- type_changed_cols: int = 0
Number of columns with changed types.
- unequal_rows: int = 0
Number of matched but unequal rows.
- unknown_rows: int = 0
Number of rows with unknown state.
- value_changed_cols: int = 0
Number of columns with changed values.
- class tabulardelta.formatters.overview_row_formatter.Header(title: str)[source]
Bases:
Row
Header added by
OverviewRowFormatter.add_header()
.Methods
get_cells() -> list[Cell | str]:
Retrieve cells from the row
- get_cells() list[Cell | str] [source]
Retrieve cells from the row.
- Returns
list[Cell | str]
: Returns cells such that they can be casted using
tabulartext.Table.from_lists()
.
- Returns
- title: str
Title of the header.
- class tabulardelta.formatters.overview_row_formatter.OverviewRowFormatter(warnings: bool = True, errors: bool = True, state: list[~tabulardelta.formatters.overview_row_formatter.Row] = <factory>)[source]
Bases:
object
Implements
Formatter
protocol for combining multiple comparisons.This formatter is stateful to accumulate TabularDelta comparisons as rows.
Additional rows can be added using add_str, add_row, add_header, and add_legend. Call table() to retrieve the table, which by default resets the state of the formatter.
Methods
format(delta: TabularDelta) -> None:
Stores comparison as row in internal state
add_header(title: str = “ TABLE”) -> None:
Add header row to internal state
add_legend() -> None:
Add legend as rows to internal state
add_str(row: str) -> None:
Add string as row to internal state
add_row(char: str, name: str, rows: int, cols: int) -> None:
Manually add table as row to internal state
table(keep_state: bool = False) -> str:
Retrieve report from internal state
- add_header(title: str = ' TABLE') None [source]
Add header row to internal state.
This should be called at least once in the beginning.
Use this method with the optional title, to separate different chunks of comparisons.
- Arguments:
- title
str
: Title describing the following tables.
- title
- Returns
None
: No return value. Use
table()
to retrieve report.
- add_legend() None [source]
Add legend as rows to internal state.
This should be called in the end, if the users aren’t familiar with the column meanings.
- Returns
None
: No return value. Use
table()
to retrieve report.
- Returns
- add_row(char: str, name: str, rows: int, cols: int) None [source]
Manually add table as row to internal state.
This is especially helpful for including added or removed tables.
add_row("+", "table", 10, 5)
will result inTABLE ROWS COLUMNS + table 10 5
- Arguments:
- char
str
: One-char summary of comparison, please refer to the legend.
- name
str
: Name of the table.
- rows
int
: Number of rows in the table.
- cols
int
: Number of columns in the table.
- char
- Returns
None
: No return value. Use
table()
to retrieve report.
- add_str(row: str) None [source]
Add string as row to internal state.
This can be used to customize the report with additional information.
- Arguments:
- row
str
: Content of the row.
- row
- Returns
None
: No return value. Use
table()
to retrieve report.
- errors: bool = True
Whether to show errors in the report.
- format(delta: TabularDelta) None [source]
Stores comparison as row in internal state.
- Arguments:
- delta
TabularDelta
: Metadata and result of a comparison.
- delta
- Returns
None
: No return value. Use
table()
to retrieve report.
- state: list[Row]
Internal state of the formatter.
May be used to do custom modifications/analyses. May change.
- table(keep_state: bool = False) str [source]
Retrieve report from internal state.
- Arguments:
- keep_state
bool
: Whether to keep the internal state or clean it up.
- keep_state
- Returns
str
: Table combining comparisons as rows.
- warnings: bool = True
Whether to show warnings in the report.
- class tabulardelta.formatters.overview_row_formatter.Row(*args, **kwargs)[source]
Bases:
Protocol
Protocol defining how to retrieve data from a row.
Methods
get_cells() -> list[Cell | str]:
Retrieve cells from the row
- class tabulardelta.formatters.overview_row_formatter.Single(content: str = '')[source]
Bases:
Row
Row with single cell added by
OverviewRowFormatter.add_str()
.Methods
get_cells() -> list[Cell | str]:
Retrieve cells from the row
- content: str = ''
Content of the row.
- class tabulardelta.formatters.overview_row_formatter.Triple(name: str = '', rows: str = '', cols: str = '')[source]
Bases:
Row
Row with three cells added by
OverviewRowFormatter.add_legend()
.Methods
get_cells() -> list[Cell | str]:
Retrieve cells from the row
- cols: str = ''
Content for column-changes columns.
- get_cells() list[Cell | str] [source]
Retrieve cells from the row.
- Returns
list[Cell | str]
: Returns cells such that they can be casted using
tabulartext.Table.from_lists()
.
- Returns
- name: str = ''
Content for char and name columns.
- rows: str = ''
Content for row-changes columns.