How to use the pytablewriter.style.Align 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 / test / test_style.py View on Github external
            [Style(align=Align.RIGHT), Style(align=Align.RIGHT), True],
            [Style(align=Align.RIGHT), Style(align=Align.LEFT), False],
            [Style(align=Align.RIGHT), Style(align="right"), True],
            [Style(align=Align.RIGHT), Style(align=Align.RIGHT, font_size=FontSize.TINY), False],
            [Style(font_size=FontSize.TINY), Style(font_size=FontSize.TINY), True],
            [Style(font_size=FontSize.TINY), Style(font_size="tiny"), True],
            [Style(font_size=FontSize.TINY), Style(font_size=FontSize.LARGE), False],
            [Style(font_weight="bold"), Style(font_weight=FontWeight.BOLD), True],
            [Style(font_weight="bold"), Style(font_weight="normal"), False],
            [Style(font_style="italic"), Style(font_style=FontStyle.ITALIC), True],
            [Style(font_style="italic"), Style(font_style="normal"), False],
            [Style(thousand_separator=","), Style(thousand_separator=","), True],
            [Style(thousand_separator=","), Style(thousand_separator="comma"), True],
            [Style(thousand_separator=""), Style(thousand_separator=","), False],
            [
                Style(thousand_separator=ThousandSeparator.COMMA),
                Style(thousand_separator=ThousandSeparator.COMMA),
github thombashi / pytablewriter / test / test_style.py View on Github external
                    "align": Align.RIGHT,
                    "font_size": FontSize.TINY,
                    "font_weight": FontWeight.BOLD,
                    "thousand_separator": ThousandSeparator.SPACE,
                },
            ],
            [
                {
                    "align": "left",
                    "font_size": "small",
                    "font_weight": "bold",
                    "thousand_separator": ",",
                },
                {
                    "align": Align.LEFT,
                    "font_size": FontSize.SMALL,
                    "font_weight": FontWeight.BOLD,
github thombashi / pytablewriter / pytablewriter / writer / _table_writer.py View on Github external
Typecode.STRING: True,
        }

        self._is_require_table_name = False
        self._is_require_header = False

        self.__line_break_handling = None
        self.line_break_handling = LineBreakHandling.NOP

        self.iteration_length = -1
        self.write_callback = lambda _iter_count, _iter_length: None  # NOP
        self._iter_count = None

        self.__align_list = []
        self.__align_char_mapping = {
            Align.AUTO: "<",
            Align.LEFT: "<",
            Align.RIGHT: ">",
            Align.CENTER: "^",
        }

        self.__style_list = []

        self.__clear_preprocess()
github thombashi / pytablewriter / pytablewriter / writer / text / _latex.py View on Github external
def _get_col_align_char_list(self):
        col_align_list = []

        for col_dp in self._column_dp_list:
            align = self._get_style_attr_from_style(col_dp.column_index, "align")
            if align is None or align == Align.AUTO:
                align = col_dp.align

            if align == Align.RIGHT:
                col_align = "r"
            elif align == Align.CENTER:
                col_align = "c"
            else:
                col_align = "l"

            col_align_list.append(col_align)

        return col_align_list
github thombashi / pytablewriter / pytablewriter / writer / text / _mediawiki.py View on Github external
def _get_header_format_string(self, col_dp, value_dp):
        return "! {{:{:s}{:s}}}".format(
            self._get_align_char(Align.CENTER), str(self._get_padding_len(col_dp, value_dp))
        )
github thombashi / pytablewriter / pytablewriter / writer / text / _mediawiki.py View on Github external
def __modify_table_element(self, value, value_dp):
        if value_dp.align is Align.LEFT:
            forma_stirng = "| {1:s}"
        else:
            forma_stirng = '| style="text-align:{0:s}"| {1:s}'

        if self.__RE_TABLE_SEQUENCE.search(value) is not None:
            value = "\n" + value.lstrip()

        return forma_stirng.format(value_dp.align.align_string, value)
github thombashi / pytablewriter / pytablewriter / writer / _table_writer.py View on Github external
align = self._get_style_attr_from_style(col_idx, "align")

        if not align:
            try:
                align = self.align_list[col_idx]
            except (IndexError, KeyError):
                pass

        if align is None:
            return default_align

        if align not in Align:
            self._logger.logger.debug("invalid alignment: {}".format(align))
            return default_align

        if align == Align.AUTO:
            return default_align

        return align
github thombashi / pytablewriter / pytablewriter / writer / text / _latex.py View on Github external
def _get_col_align_char_list(self):
        col_align_list = []

        for col_dp in self._column_dp_list:
            align = self._get_style_attr_from_style(col_dp.column_index, "align")
            if align is None or align == Align.AUTO:
                align = col_dp.align

            if align == Align.RIGHT:
                col_align = "r"
            elif align == Align.CENTER:
                col_align = "c"
            else:
                col_align = "l"

            col_align_list.append(col_align)

        return col_align_list