How to use the pytablewriter.writer.text._text_writer.IndentationTextTableWriter function in pytablewriter

To help you get started, we’ve selected a few pytablewriter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thombashi / pytablewriter / pytablewriter / writer / text / sourcecode / _sourcecode.py View on Github external
# encoding: utf-8

from __future__ import absolute_import, unicode_literals

import abc

import typepy

from .._text_writer import IndentationTextTableWriter


class SourceCodeTableWriter(IndentationTextTableWriter):
    """
    Base class of table writer with a source code (variable definition) format.

    .. py:attribute:: is_datetime_instance_formatting

        Write |datetime| values in the table as definition of |datetime| class
        instances coincide with specific language if this value is |True|.
        Write as |str| if this value is |False|.
    """

    @abc.abstractmethod
    def get_variable_name(self, value):  # pragma: no cover
        pass

    @property
    def variable_name(self):
github thombashi / pytablewriter / pytablewriter / writer / text / _latex.py View on Github external
# encoding: utf-8

from __future__ import absolute_import, unicode_literals

import copy
import re

import dataproperty as dp
import typepy
from typepy import Typecode

from ...style import Align, LatexStyler
from ._text_writer import IndentationTextTableWriter


class LatexWriter(IndentationTextTableWriter):
    """
    A base writer class for LaTeX format.
    """

    _RE_MATH_PARTS = re.compile("^[\\]?[a-zA-z]+$")

    @property
    def support_split_write(self):
        return True

    def __init__(self):
        super(LatexWriter, self).__init__()

        self.is_write_opening_row = True
        self.is_write_closing_row = True
        self.indent_string = "    "
github thombashi / pytablewriter / pytablewriter / writer / text / _markdown.py View on Github external
# encoding: utf-8

from __future__ import absolute_import, unicode_literals

import copy

import dataproperty as dp
import typepy
from mbstrdecoder import MultiByteStrDecoder

from ...style import Align, MarkdownStyler
from ._text_writer import IndentationTextTableWriter


class MarkdownTableWriter(IndentationTextTableWriter):
    """
    A table writer class for Markdown format.

        :Example:
            :ref:`example-markdown-table-writer`
    """

    FORMAT_NAME = "markdown"

    @property
    def format_name(self):
        return self.FORMAT_NAME

    @property
    def support_split_write(self):
        return True
github thombashi / pytablewriter / pytablewriter / writer / text / _rst.py View on Github external
# encoding: utf-8

from __future__ import absolute_import, unicode_literals

import copy

import dataproperty
import typepy
from mbstrdecoder import MultiByteStrDecoder

from ...style import ReStructuredTextStyler
from ._text_writer import IndentationTextTableWriter


class RstTableWriter(IndentationTextTableWriter):
    """
    A base class of reStructuredText table writer.
    """

    def __init__(self):
        super(RstTableWriter, self).__init__()

        self.table_name = ""
        self.char_header_row_separator = "="
        self.char_cross_point = "+"
        self.char_left_cross_point = "+"
        self.char_right_cross_point = "+"
        self.char_top_left_cross_point = "+"
        self.char_top_right_cross_point = "+"
        self.char_bottom_left_cross_point = "+"
        self.char_bottom_right_cross_point = "+"
github thombashi / pytablewriter / pytablewriter / writer / text / _json.py View on Github external
from mbstrdecoder import MultiByteStrDecoder
from six.moves import zip
from typepy import Typecode

from ..._converter import strip_quote
from ._common import bool_to_str
from ._text_writer import IndentationTextTableWriter


try:
    import simplejson as json
except ImportError:
    import json


class JsonTableWriter(IndentationTextTableWriter):
    """
    A table writer class for JSON format.

        :Examples:
            :ref:`example-json-table-writer`

    .. py:method:: write_table

        |write_table| with JSON format.

        :raises pytablewriter.EmptyHeaderError: If the |headers| is empty.
        :Examples:
            :ref:`example-json-table-writer`

        .. note::
            Specific values in the tabular data are converted when writing:
github thombashi / pytablewriter / pytablewriter / writer / text / _text_writer.py View on Github external
def __init__(self):
        super(IndentationTextTableWriter, self).__init__()

        self.set_indent_level(0)
        self.indent_string = ""
github thombashi / pytablewriter / pytablewriter / writer / text / _rst.py View on Github external
def write_table(self):
        """
        |write_table| with reStructuredText CSV table format.

        :raises pytablewriter.EmptyTableDataError:
            If the |headers| and the |value_matrix| is empty.
        :Example:
            :ref:`example-rst-csv-table-writer`

        .. note::
            - |None| values are written as an empty string
        """

        IndentationTextTableWriter.write_table(self)