flexget.terminal module#
- class flexget.terminal.TerminalTable(*args, table_type=None, **kwargs)[source]#
Bases:
TableA data table suited for CLI output, created via its sent parameters.
For example:
header = ['Col1', 'Col2'] table_data = [header] for item in iterable: table_data.append([item.attribute1, item.attribute2]) table = TerminalTable('plain', table_data) print table.output
Optional values are setting table title, and supplying wrap_columns list and drop_column list. If table does not fit into terminal any columns listed in wrap_columns will be tried to wrap and if resulting columns are below MIN_WIDTH(10) columns listed in drop_column will be removed from output.
Example:
header = ['Col1', 'Col2'] table_data = [header] for item in iterable: table_data.append([item.attribute1, item.attribute2]) table = TerminalTable('plain', table_data, 'Table title', wrap_columns=[1,2], drop_columns=[4,2]) print table.output
- Parameters:
table_type (str | None) – A string matching TABLE_TYPES keys.
- class Column(header='', footer='', header_style='', footer_style='', style='', justify='left', vertical='top', overflow='ellipsis', width=None, min_width=None, max_width=None, ratio=None, no_wrap=False, highlight=False, _index=0, _cells=<factory>)#
Bases:
objectDefines a column within a ~Table.
- Args:
title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None. caption (Union[str, Text], optional): The table caption rendered below. Defaults to None. width (int, optional): The width in characters of the table, or
Noneto automatically fit. Defaults to None. min_width (Optional[int], optional): The minimum width of the table, orNonefor no minimum. Defaults to None. box (box.Box, optional): One of the constants in box.py used to draw the edges (see Box), orNonefor no box lines. Defaults to box.HEAVY_HEAD. safe_box (Optional[bool], optional): Disable box characters that don’t display on windows legacy terminal with raster fonts. Defaults to True. padding (PaddingDimensions, optional): Padding for cells (top, right, bottom, left). Defaults to (0, 1). collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to False. pad_edge (bool, optional): Enable padding of edge cells. Defaults to True. show_header (bool, optional): Show a header row. Defaults to True. show_footer (bool, optional): Show a footer row. Defaults to False. show_edge (bool, optional): Draw a box around the outside of the table. Defaults to True. show_lines (bool, optional): Draw lines between every row. Defaults to False. leading (int, optional): Number of blank lines between rows (precludesshow_lines). Defaults to 0. style (Union[str, Style], optional): Default style for the table. Defaults to “none”. row_styles (List[Union, str], optional): Optional list of row styles, if more than one style is given then the styles will alternate. Defaults to None. header_style (Union[str, Style], optional): Style of the header. Defaults to “table.header”. footer_style (Union[str, Style], optional): Style of the footer. Defaults to “table.footer”. border_style (Union[str, Style], optional): Style of the border. Defaults to None. title_style (Union[str, Style], optional): Style of the title. Defaults to None. caption_style (Union[str, Style], optional): Style of the caption. Defaults to None. title_justify (str, optional): Justify method for title. Defaults to “center”. caption_justify (str, optional): Justify method for caption. Defaults to “center”. highlight (bool, optional): Highlight cell contents (if str). Defaults to False.
- Parameters:
header (RenderableType)
footer (RenderableType)
header_style (str | Style)
footer_style (str | Style)
style (str | Style)
justify (JustifyMethod)
vertical (VerticalAlignMethod)
overflow (OverflowMethod)
width (int | None)
min_width (int | None)
max_width (int | None)
ratio (int | None)
no_wrap (bool)
highlight (bool)
_index (int)
_cells (List[RenderableType])
RenderableType: Renderable for the footer (typically a string)
StyleType: The style of the footer.
- header: RenderableType = ''#
RenderableType: Renderable for the header (typically a string)
- justify: JustifyMethod = 'left'#
str: How to justify text within the column (“left”, “center”, “right”, or “full”)
- max_width: int | None = None#
Optional[int]: Maximum width of column, or
Nonefor no maximum. Defaults to None.
- min_width: int | None = None#
Optional[int]: Minimum width of column, or
Nonefor no minimum. Defaults to None.
- overflow: OverflowMethod = 'ellipsis'#
str: Overflow method.
- ratio: int | None = None#
Optional[int]: Ratio to use when calculating column width, or
None(default) to adapt to column contents.
- vertical: VerticalAlignMethod = 'top'#
str: How to vertically align content (“top”, “middle”, or “bottom”)
- TABLE_TYPES = {'double': {'box': Box(...)}, 'github': {'box': Box(...)}, 'heavy-head': {'box': Box(...)}, 'plain': {'box': Box(...)}, 'porcelain': {'box': Box(...), 'pad_edge': False, 'padding': 0, 'show_edge': False, 'title': None}, 'single': {'box': Box(...)}}#
- class flexget.terminal._Console(*args, **kwargs)[source]#
Bases:
Console- rule(title='', *, characters='─', style='rule.line', align='left', indent=3)[source]#
Draw a line with optional centered title.
- Args:
title (str, optional): Text to render over the rule. Defaults to “”. characters (str, optional): Character(s) to form the line. Defaults to “─”. style (str, optional): Style of line. Defaults to “rule.line”. align (str, optional): How to align the title, one of “left”, “center”, or “right”. Defaults to “center”.
- flexget.terminal.capture_console(filelike)[source]#
- Parameters:
filelike (TextIO)
- Return type:
Iterator