tablate.api package#
Subpackages#
Submodules#
tablate.api.Tablate module#
- class tablate.api.Tablate.Tablate(container_border=None, container_padding=None, container_width=None, html_default_colors=None, frame_divider=None, background=None, background_padding=None, html_px_multiplier=None, html_container_styles=None, column_styles=None, text_styles=None, html_frame_styles=None, html_column_styles=None, html_text_styles=None)[source]#
Bases:
TablateApiSetContainer for text, grid and table frames. Allows cumulative addition of frames to an instance.
- Note:
When using the ‘Tablate’ class in an IPython environment, it is important to name each frame (or else rerunning cells will create duplicate entries).
- Parameters:
container_border (
Optional[Literal['blank','thin','thick','double']]) – outer border style for the Tablate container instance. [default: ‘thick’]container_padding (
Optional[int]) – outer padding (in Unicode character width) for the Tablate container instance. [default: 1]container_width (
Optional[int]) – outer width (in Unicode character width) for the Tablate container instance. [default: 120 or terminal width]html_default_colors (
Optional[bool]) – apply the default HTML color scheme to the Tablate instance. [default: True]frame_divider (
Optional[Literal['none','blank','thin','thick','double']]) – default dividing line between frames within the Tablate container instance. [default: ‘thick’]background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – default background for frames withing the Tablate container instance. [default: None]background_padding (
Optional[int]) – additional padding applied to cells with a background color set (ASCII only). [default: 1]html_px_multiplier (
Optional[int]) – Multiplier applied to HTML px properties. [default: 1]html_container_styles (
Optional[HtmlContainerStylesInput]) – style dictionary for HTML specific styles for Tablate container instance. [default: None]column_styles (
Optional[ColumnStylesInput]) – style dictionary for default base column styles. [default: {“column_divider”: ‘thin’, “padding”: 1, “background_padding”: 1}]text_styles (
Optional[TextStylesInput]) – style dictionary for default base text styles. [default: { “text_style”: ‘normal’, “text_align”: ‘left’, “text_color”: None }]html_frame_styles (
Optional[HtmlFrameStylesInput]) –style dictionary for default HTML specific frame styles. [default: {
“html_frame_divider_style”: “thick”, “html_frame_divider_weight: 1, “html_frame_divider_color”: ‘black’, “html_multiline”: True (False for Table frames), “html_max_lines”: None, “html_background”: None }]
html_column_styles (
Optional[HtmlColumnStylesInput]) – style dictionary for default HTML specific column styles. [default: { “html_column_divider_style”: ‘thin’, “html_column_divider_weight”: 1, “html_column_divider_color”: ‘black’, “html_padding”: 6px }]html_text_styles (
Optional[HtmlTextStylesInput]) – style dictionary for default HTML specific text styles. [default: { “html_text_style”: ‘normal’, “html_text_align”: ‘left’, “html_text_color”: None, “html_text_size”: 16 }]
- add_text_frame(text, name=None, text_style=None, text_align=None, text_color=None, frame_divider=None, frame_padding=None, background=None, background_padding=None, multiline=None, max_lines=None, html_px_multiplier=None, html_styles=None)[source]#
Add a new text frame (single row, single column) to Tablate container instance.
- Parameters:
text (
Union[str,int,float]) – Text frame content. [required]name (
Optional[str]) – Frame name (to prevent duplicate entries). [default: None]text_style (
Optional[Literal['normal','bold','underlined','bold_underlined']]) – Text style for text frame. [default: ‘normal’]text_align (
Optional[Literal['left','center','right']]) – Text alignment for text frame. [default: ‘left’]text_color (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Text color for text frame. [default: ‘None’]frame_divider (
Optional[Literal['none','blank','thin','thick','double']]) – Dividing line at the bottom of the frame. [default: ‘thick’]frame_padding (
Optional[int]) – Text padding within text frame. [default: 1]background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Background color for the text frame. [default: None]background_padding (
Optional[int]) – Additional padding applied to text if background color set (ASCII only). [default: 1]multiline (
Optional[bool]) – Whether the text may wrap to multiple lines. [default: True]max_lines (
Optional[int]) – Maximum number of lines to which the text may wrap. [default: None]html_px_multiplier (
Optional[int]) – Multiplier applied to HTML px properties. [default: 1]html_styles (
Optional[HtmlTextFrameStylesInput]) – HTML specific styles for text frame. [default: { “html_frame_styles”: {“html_frame_divider_style”: “thick”, “html_frame_divider_weight: 1, “html_frame_divider_color”: ‘black’, “html_multiline”: True (False for Table frames), “html_max_lines”: None, “html_background”: None }, “html_text_styles”: {“html_text_style”: ‘normal’, “html_text_align”: ‘left’, “html_text_color”: None, “html_text_size”: 16 } }]
- Return type:
None
- add_grid_frame(columns, name=None, frame_divider=None, background=None, background_padding=None, multiline=None, max_lines=None, column_divider=None, column_padding=None, text_style=None, text_align=None, text_color=None, html_px_multiplier=None, html_styles=None)[source]#
Add a new grid frame (single row of multiple columns) to Tablate instance.
- Parameters:
columns (
List[Union[str,GridColumnInput]]) – Either a list of contents (str, int, float) for columns or a list of column dicts containing contents and styles for columns. [required]name (
Optional[str]) – Frame name (to prevent duplicate entries). [default: None]frame_divider (
Optional[Literal['none','blank','thin','thick','double']]) – Dividing line at the bottom of the frame. [default: ‘thick’]background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Background color for the grig frame. [default: None]background_padding (
Optional[int]) – Additional padding applied to text if background color set (ASCII only). [default: 1]multiline (
Optional[bool]) – Whether the text may wrap to multiple lines. [default: True]max_lines (
Optional[int]) – Maximum number of lines to which the text may wrap. [default: None]column_divider (
Optional[Literal['blank','thin','thick','double']]) – Dividing line between columns. [default: ‘thin’]column_padding (
Optional[int]) – Text padding within each column. [default: 1]text_style (
Optional[Literal['normal','bold','underlined','bold_underlined']]) – Text style for grid frame. [default: ‘normal’]text_align (
Optional[Literal['left','center','right']]) – Text alignment for grid frame. [default: ‘left’]text_color (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Text color for grid frame. [default: ‘None’]html_px_multiplier (
Optional[int]) – Multiplier applied to HTML px properties. [default: 1]html_styles (
Optional[HtmlStylesInput]) – HTML specific styles for grid frame. [default: { “html_frame_styles”: {“html_frame_divider_style”: “thick”, “html_frame_divider_weight: 1, “html_frame_divider_color”: ‘black’, “html_multiline”: True (False for Table frames), “html_max_lines”: None, “html_background”: None }, “html_column_styles”: {“html_column_divider_style”: “thin”, “html_column_divider_weight”: 1, “html_column_divider_color”: “black”, “html_padding”: “6px”} “html_text_styles”: {“html_text_style”: ‘normal’, “html_text_align”: ‘left’, “html_text_color”: None, “html_text_size”: 16 } }]
- Return type:
None
- add_table_frame(columns, rows, name=None, frame_divider=None, background=None, background_padding=None, multiline=None, max_lines=None, multiline_header=None, max_lines_header=None, hide_header=None, column_divider=None, column_padding=None, header_base_divider=None, row_line_divider=None, odd_row_background=None, even_row_background=None, text_style=None, text_align=None, text_color=None, header_styles=None, html_px_multiplier=None, html_styles=None, html_header_styles=None)[source]#
Add a new table frame (multiple rows of multiple columns) to Tablate instance.
- Parameters:
columns (
List[TableColumnInput]) – List of column dicts containing a required column key and optional (str, int, float) to display, as well as column specific styling options. [required]rows (
List[Dict[str,Union[str,int,float]]]) – List of row dicts containing the (str, int, float) values for each column key. [required]name (
Optional[str]) – Frame name (to prevent duplicate entries). [default: None]frame_divider (
Optional[Literal['none','blank','thin','thick','double']]) – Dividing line at the bottom of the frame. [default: ‘thick’]background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Background color for the table frame. [default: None]background_padding (
Optional[int]) – Additional padding applied to text if background color set (ASCII only). [default: 1]multiline (
Optional[bool]) – Whether the text may wrap to multiple lines. [default: False]max_lines (
Optional[int]) – Maximum number of lines to which the text may wrap. [default: None]multiline_header (
Optional[bool]) – Whether the header text may wrap to multiple lines. [default: False]max_lines_header (
Optional[int]) – Maximum number of lines to which the header text may wrap. [default: None]hide_header (
Optional[bool]) – Whether to not render the header. [default: False]column_divider (
Optional[Literal['blank','thin','thick','double']]) – Dividing line between columns. [default: ‘thin’]column_padding (
Optional[int]) – Text padding within each column. [default: 1]header_base_divider (
Optional[Literal['none','blank','thin','thick','double']]) – Dividing line at the bottom of the table header frame. [default: ‘thick’]row_line_divider (
Optional[Literal['none','blank','thin','thick','double']]) – Dividing line between each row of the table frame. [default: ‘thin’]odd_row_background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Background color for odd rows of table frame. [default: None]even_row_background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Background color for even rows of table frame. [default: None]text_style (
Optional[Literal['normal','bold','underlined','bold_underlined']]) – Text style for table frame. [default: ‘normal’]text_align (
Optional[Literal['left','center','right']]) – Text alignment for table frame. [default: ‘left’]text_color (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Text color for grid frame. [default: None]header_styles (
Optional[BaseStylesInput]) – Specific styles to apply to the table header frame. [default: None (inherits table styles)]html_px_multiplier (
Optional[int]) – Multiplier applied to HTML px properties. [default: 1]html_styles (
Optional[HtmlTableFrameStylesInput]) – HTML specific styles for table frame. [default: { “html_frame_styles”: {“html_frame_divider_style”: “thick”, “html_frame_divider_weight: 1, “html_frame_divider_color”: ‘black’, “html_multiline”: True (False for Table frames), “html_max_lines”: None, “html_background”: None }, “html_column_styles”: {“html_column_divider_style”: “thin”, “html_column_divider_weight”: 1, “html_column_divider_color”: “black”, “html_padding”: “6px”}, “html_text_styles”: {“html_text_style”: ‘normal’, “html_text_align”: ‘left’, “html_text_color”: None, “html_text_size”: 16 }, “html_row_styles”: {“html_row_line_divider_weight”: 1, “html_row_line_divider_style”: “thin”, “html_row_line_divider_color”: None, “html_odds_background”: None, “html_evens_background”: None} }] (Tablate constructor option html_default_colors applies styles to table headers and even rows, separately from, but overwritten by, this html_styles dict)html_header_styles (
Optional[HtmlStylesInput]) – HTML specific styles for table header frame. [default: None (inherits table styles)]
- Return type:
None
- from_dict(dict_object, name=None, capitalize_keys=True, frame_divider=None, multiline=None, max_lines=None, background=None, background_padding=None, multiline_header=None, max_lines_header=None, hide_header=None, column_divider=None, column_padding=None, header_base_divider=None, row_line_divider=None, odd_row_background=None, even_row_background=None, text_style=None, text_align=None, text_color=None, header_styles=None, html_px_multiplier=None, html_styles=None, html_header_styles=None)[source]#
- Creates a table frame from a dict in three possible formats:
{“one”: [1, 2, 3], “two”: [4, 5, 6]}
{‘one’: {0: 1, 1: 2, 2: 3}, ‘two’: {0: 1, 1: 2, 2: 3}}
{‘one’: {(1, ‘red’): 1, (1, ‘blue’): 2, (2, ‘green’): 3}, ‘two’: {(1, ‘red’): 1, (1, ‘blue’): 2, (2, ‘green’): 3}
Pandas returns the latter two dict types from its .to_dict() method.
- Parameters:
dict_object (
dict) – Input dict. [required]name (
Optional[str]) – Frame name (to prevent duplicate entries). [default: None]capitalize_keys (
bool) – Whether to capitalize Pandas column keys. [default: True]frame_divider (
Optional[Literal['none','blank','thin','thick','double']]) – Dividing line at the bottom of the frame. [default: ‘thick’]background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Background color for the table frame. [default: None]background_padding (
Optional[int]) – Additional padding applied to text if background color set (ASCII only). [default: 1]multiline (
Optional[bool]) – Whether the text may wrap to multiple lines. [default: False]max_lines (
Optional[int]) – Maximum number of lines to which the text may wrap. [default: None]multiline_header (
Optional[bool]) – Whether the header text may wrap to multiple lines. [default: False]max_lines_header (
Optional[int]) – Maximum number of lines to which the header text may wrap. [default: None]hide_header (
Optional[bool]) – Whether to not render the header. [default: False]column_divider (
Optional[Literal['blank','thin','thick','double']]) – Dividing line between columns. [default: ‘thin’]column_padding (
Optional[int]) – Text padding within each column. [default: 1]header_base_divider (
Optional[Literal['none','blank','thin','thick','double']]) – Dividing line at the bottom of the table header frame. [default: ‘thick’]row_line_divider (
Optional[Literal['none','blank','thin','thick','double']]) – Dividing line between each row of the table frame. [default: ‘thin’]odd_row_background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Background color for odd rows of table frame. [default: None]even_row_background (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Background color for even rows of table frame. [default: None]text_style (
Optional[Literal['normal','bold','underlined','bold_underlined']]) – Text style for table frame. [default: ‘normal’]text_align (
Optional[Literal['left','center','right']]) – Text alignment for table frame. [default: ‘left’]text_color (
Optional[Literal['white','grey','red','green','yellow','blue','magenta','cyan','dark_red','dark_green','dark_yellow','dark_blue','dark_magenta','dark_cyan','dark_grey','black']]) – Text color for grid frame. [default: None]header_styles (
Optional[BaseStylesInput]) – Specific styles to apply to the table header frame. [default: None (inherits table styles)]html_px_multiplier (
Optional[int]) – Multiplier applied to HTML px properties. [default: 1]html_styles (
Optional[HtmlTableFrameStylesInput]) – HTML specific styles for table frame. [default: { “html_frame_styles”: {“html_frame_divider_style”: “thick”, “html_frame_divider_weight: 1, “html_frame_divider_color”: ‘black’, “html_multiline”: True (False for Table frames), “html_max_lines”: None, “html_background”: None }, “html_column_styles”: {“html_column_divider_style”: “thin”, “html_column_divider_weight”: 1, “html_column_divider_color”: “black”, “html_padding”: “6px”}, “html_text_styles”: {“html_text_style”: ‘normal’, “html_text_align”: ‘left’, “html_text_color”: None, “html_text_size”: 16 }, “html_row_styles”: {“html_row_line_divider_weight”: 1, “html_row_line_divider_style”: “thin”, “html_row_line_divider_color”: None, “html_odds_background”: None, “html_evens_background”: None} }] (Tablate constructor option html_default_colors applies styles to table headers and even rows, separately from, but overwritten by, this html_styles dict)html_header_styles (
Optional[HtmlStylesInput]) – HTML specific styles for table header frame. [default: None (inherits table styles)]