Renderers
- class rolumns.renderers.MarkdownRenderer(columns: Columns, mask: Optional[List[str]] = None)[source]
Renders the set of columns
columns
to an iterable list of strings that make up a Markdown table row-by-row.All columns will be rendered by default. To specify columns and their order, pass
mask
and/or callMarkdownRenderer.append()
.from rolumns import Columns from rolumns.renderers import MarkdownRenderer data = [ { "name": "Robert Pringles", "email": "bob@pringles.pop", }, { "name": "Daniel Sausage", "email": "danny@pringles.pop", }, { "name": "Charlie Marmalade", "email": "charlie@pringles.pop", }, ] columns = Columns() columns.add("Name", "name") columns.add("Email", "email") renderer = MarkdownRenderer(columns) rows = renderer.render(data) print(list(rows))
['| Name | Email |', '| - | - |', '| Robert Pringles | bob@pringles.pop |', '| Daniel Sausage | danny@pringles.pop |', '| Charlie Marmalade | charlie@pringles.pop |']
- append(column: str, alignment: Optional[ColumnAlignment] = None) None [source]
Appends a column to the table.
- static pad(value: str, length: int, align: Optional[ColumnAlignment] = None) str [source]
Pads a string to a displayable width.
- class rolumns.renderers.RowsRenderer(columns: Columns, mask: Optional[List[str]] = None)[source]
Renders the set of columns
columns
to an iterable list of rows.All columns will be rendered by default. To specify columns and their order, pass
mask
and/or callRowsRenderer.append()
.