5.1.4.2. Base writer classes of text formats

class pytablewriter.writer.text._text_writer.TextTableWriter(**kwargs)[source]

Bases: pytablewriter.writer._table_writer.AbstractTableWriter, pytablewriter.writer.text._interface.TextWriterInterface

A base class for table writer with text formats.

table_char

Character attributes that compose a table

column_delimiter: str

A column delimiter of a table.

char_left_side_row: str

A character of a left side of a row.

char_right_side_row: str

A character of a right side of a row.

char_cross_point: str

A character of the crossing point of column delimiter and row delimiter.

char_opening_row: str

A character of the first line of a table.

char_header_row_separator: str

A character of a separator line of the header and the body of the table.

char_value_row_separator: str

A character of a row separator line of the table.

char_closing_row: str

A character of the last line of a table.

is_write_header_separator_row: bool

Write a header separator line of the table if the value is True.

is_write_value_separator_row: bool

Write row separator line(s) of the table if the value is True.

is_write_opening_row: bool

Write an opening line of the table if the value is True.

is_write_closing_row: bool

Write a closing line of the table if the value is True.

is_write_null_line_after_table: bool

Write a blank line of after writing a table if the value is True.

margin: int

Margin size for each cells

clear_theme() → None[source]

Remove all of the style filters.

dump(output: Union[str, IO], close_after_write: bool = True, **kwargs) → None[source]

Write data to the output with tabular format.

During the executing this method, enable_ansi_escape attribute will be temporarily set to False.

Parameters
  • output – The value must either an output stream or a path to an output file.

  • close_after_write – Close the output after write. Defaults to True.

dumps(**kwargs) → str[source]

Get rendered tabular text from the table data.

Only available for text format table writers.

Parameters

**kwargs – Optional arguments that the writer takes.

Returns

Rendered tabular text.

Return type

str

write_null_line() → None[source]

Write a null line to the stream.

write_table(**kwargs) → None[source]

Write a table to the stream.

Note

  • None values are written as an empty string.

class pytablewriter.writer.text._text_writer.IndentationTextTableWriter(**kwargs)[source]

Bases: pytablewriter.writer.text._text_writer.TextTableWriter, pytablewriter.writer.text._interface.IndentationInterface

A base class for table writer with indentation text formats.

Parameters

indent_level (int) – Indentation level. Defaults to 0.

indent_string

Indentation string for each level.

dec_indent_level() → None[source]

Decrement the indentation level.

inc_indent_level() → None[source]

Increment the indentation level.

set_indent_level(indent_level: int) → None[source]

Set the indentation level.

Parameters

indent_level (int) – New indentation level.

write_table(**kwargs) → None[source]

Write a table to the stream.

Parameters

indent (Optional[int]) – Indent level of an output. Interpretation of indent level value differ format to format. Some writer classes may ignore this value.

Note

  • None values are written as an empty string.