How to use the beautifultable.enums.WidthExceedPolicy function in beautifultable

To help you get started, we’ve selected a few beautifultable 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 pri22296 / beautifultable / beautifultable / rows.py View on Github external
):

            # Let's strip the row
            delimiter = "" if wep is WidthExceedPolicy.WEP_STRIP else "..."
            row_item_list = []
            for index, row_item in enumerate(row):
                left_pad = table._column_pad * lpw[index]
                right_pad = table._column_pad * rpw[index]
                clmp_str = (
                    left_pad
                    + self._clamp_string(row_item, index, delimiter)
                    + right_pad
                )
                row_item_list.append(clmp_str)
            list_of_rows.append(row_item_list)
        elif wep is WidthExceedPolicy.WEP_WRAP:

            # Let's wrap the row
            string_partition = []

            for index, row_item in enumerate(row):
                width = table.column_widths[index] - lpw[index] - rpw[index]
                string_partition.append(textwrap(row_item, width))

            for row_items in zip_longest(*string_partition, fillvalue=""):
                row_item_list = []
                for index, row_item in enumerate(row_items):
                    left_pad = table._column_pad * lpw[index]
                    right_pad = table._column_pad * rpw[index]
                    row_item_list.append(left_pad + row_item + right_pad)
                list_of_rows.append(row_item_list)
github pri22296 / beautifultable / beautifultable / enums.py View on Github external
STYLE_DOTTED = DottedStyle
    STYLE_MYSQL = MySQLStyle
    STYLE_SEPARATED = SeparatedStyle
    STYLE_COMPACT = CompactStyle
    STYLE_MARKDOWN = MarkdownStyle
    STYLE_RST = RestructuredTextStyle
    STYLE_BOX = BoxStyle
    STYLE_BOX_DOUBLED = DoubledBoxStyle
    STYLE_BOX_ROUNDED = RoundedStyle
    STYLE_GRID = GridStyle

    def __repr__(self):
        return self.name


WEP_WRAP = WidthExceedPolicy.WEP_WRAP
WEP_STRIP = WidthExceedPolicy.WEP_STRIP
WEP_ELLIPSIS = WidthExceedPolicy.WEP_ELLIPSIS
SM_PLUS = SignMode.SM_PLUS
SM_MINUS = SignMode.SM_MINUS
SM_SPACE = SignMode.SM_SPACE
ALIGN_LEFT = Alignment.ALIGN_LEFT
ALIGN_CENTER = Alignment.ALIGN_CENTER
ALIGN_RIGHT = Alignment.ALIGN_RIGHT
STYLE_DEFAULT = Style.STYLE_DEFAULT
STYLE_NONE = Style.STYLE_NONE
STYLE_DOTTED = Style.STYLE_DOTTED
STYLE_SEPARATED = Style.STYLE_SEPARATED
STYLE_COMPACT = Style.STYLE_COMPACT
STYLE_MYSQL = Style.STYLE_MYSQL
STYLE_MARKDOWN = Style.STYLE_MARKDOWN
STYLE_RST = Style.STYLE_RST
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
# Let's strip the row
            delimiter = (
                "" if wep is enums.WidthExceedPolicy.WEP_STRIP else "..."
            )
            row_item_list = []
            for index, row_item in enumerate(row):
                left_pad = table.columns._pad_character * lpw[index]
                right_pad = table.columns._pad_character * rpw[index]
                clmp_str = (
                    left_pad
                    + self._clamp_string(row_item, index, delimiter)
                    + right_pad
                )
                row_item_list.append(clmp_str)
            result.append(row_item_list)
        elif wep is enums.WidthExceedPolicy.WEP_WRAP:

            # Let's wrap the row
            string_partition = []

            for index, row_item in enumerate(row):
                width = table.columns.width[index] - lpw[index] - rpw[index]
                string_partition.append(textwrap(row_item, width))

            for row_items in zip_longest(*string_partition, fillvalue=""):
                row_item_list = []
                for index, row_item in enumerate(row_items):
                    left_pad = table.columns._pad_character * lpw[index]
                    right_pad = table.columns._pad_character * rpw[index]
                    row_item_list.append(left_pad + row_item + right_pad)
                result.append(row_item_list)
github pri22296 / beautifultable / beautifultable / enums.py View on Github external
STYLE_SEPARATED = SeparatedStyle
    STYLE_COMPACT = CompactStyle
    STYLE_MARKDOWN = MarkdownStyle
    STYLE_RST = RestructuredTextStyle
    STYLE_BOX = BoxStyle
    STYLE_BOX_DOUBLED = DoubledBoxStyle
    STYLE_BOX_ROUNDED = RoundedStyle
    STYLE_GRID = GridStyle

    def __repr__(self):
        return self.name


WEP_WRAP = WidthExceedPolicy.WEP_WRAP
WEP_STRIP = WidthExceedPolicy.WEP_STRIP
WEP_ELLIPSIS = WidthExceedPolicy.WEP_ELLIPSIS
SM_PLUS = SignMode.SM_PLUS
SM_MINUS = SignMode.SM_MINUS
SM_SPACE = SignMode.SM_SPACE
ALIGN_LEFT = Alignment.ALIGN_LEFT
ALIGN_CENTER = Alignment.ALIGN_CENTER
ALIGN_RIGHT = Alignment.ALIGN_RIGHT
STYLE_DEFAULT = Style.STYLE_DEFAULT
STYLE_NONE = Style.STYLE_NONE
STYLE_DOTTED = Style.STYLE_DOTTED
STYLE_SEPARATED = Style.STYLE_SEPARATED
STYLE_COMPACT = Style.STYLE_COMPACT
STYLE_MYSQL = Style.STYLE_MYSQL
STYLE_MARKDOWN = Style.STYLE_MARKDOWN
STYLE_RST = Style.STYLE_RST
STYLE_BOX = Style.STYLE_BOX
STYLE_BOX_DOUBLED = Style.STYLE_BOX_DOUBLED
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
def width_exceed_policy(self, value):
        if not isinstance(value, enums.WidthExceedPolicy):
            allowed = (
                "{}.{}".format(type(self).__name__, i.name)
                for i in enums.WidthExceedPolicy
            )
            error_msg = (
                "allowed values for width_exceed_policy are: "
                + ", ".join(allowed)
            )
            raise ValueError(error_msg)
        self._width_exceed_policy = value
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
Returns
        -------
        list of list:
            List representation of the `row` after it has been processed
            according to width exceed policy.
        """
        table = self._table
        lpw, rpw = self._get_padding()
        wep = table.columns.width_exceed_policy

        result = []

        if (
            wep is enums.WidthExceedPolicy.WEP_STRIP
            or wep is enums.WidthExceedPolicy.WEP_ELLIPSIS
        ):

            # Let's strip the row
            delimiter = (
                "" if wep is enums.WidthExceedPolicy.WEP_STRIP else "..."
            )
            row_item_list = []
            for index, row_item in enumerate(row):
                left_pad = table.columns._pad_character * lpw[index]
                right_pad = table.columns._pad_character * rpw[index]
                clmp_str = (
                    left_pad
                    + self._clamp_string(row_item, index, delimiter)
                    + right_pad
                )
                row_item_list.append(clmp_str)
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
def width_exceed_policy(self, value):
        if not isinstance(value, enums.WidthExceedPolicy):
            allowed = (
                "{}.{}".format(type(self).__name__, i.name)
                for i in enums.WidthExceedPolicy
            )
            error_msg = (
                "allowed values for width_exceed_policy are: "
                + ", ".join(allowed)
            )
            raise ValueError(error_msg)
        self._width_exceed_policy = value
github pri22296 / beautifultable / beautifultable / rows.py View on Github external
A single row.

        Returns
        -------
        list of list:
            List representation of the `row` after it has been processed
            according to width exceed policy.
        """
        table = self._table
        lpw, rpw = table.left_padding_widths, table.right_padding_widths
        wep = table.width_exceed_policy

        list_of_rows = []

        if (
            wep is WidthExceedPolicy.WEP_STRIP
            or wep is WidthExceedPolicy.WEP_ELLIPSIS
        ):

            # Let's strip the row
            delimiter = "" if wep is WidthExceedPolicy.WEP_STRIP else "..."
            row_item_list = []
            for index, row_item in enumerate(row):
                left_pad = table._column_pad * lpw[index]
                right_pad = table._column_pad * rpw[index]
                clmp_str = (
                    left_pad
                    + self._clamp_string(row_item, index, delimiter)
                    + right_pad
                )
                row_item_list.append(clmp_str)
            list_of_rows.append(row_item_list)
github pri22296 / beautifultable / beautifultable / enums.py View on Github external
STYLE_MYSQL = MySQLStyle
    STYLE_SEPARATED = SeparatedStyle
    STYLE_COMPACT = CompactStyle
    STYLE_MARKDOWN = MarkdownStyle
    STYLE_RST = RestructuredTextStyle
    STYLE_BOX = BoxStyle
    STYLE_BOX_DOUBLED = DoubledBoxStyle
    STYLE_BOX_ROUNDED = RoundedStyle
    STYLE_GRID = GridStyle

    def __repr__(self):
        return self.name


WEP_WRAP = WidthExceedPolicy.WEP_WRAP
WEP_STRIP = WidthExceedPolicy.WEP_STRIP
WEP_ELLIPSIS = WidthExceedPolicy.WEP_ELLIPSIS
SM_PLUS = SignMode.SM_PLUS
SM_MINUS = SignMode.SM_MINUS
SM_SPACE = SignMode.SM_SPACE
ALIGN_LEFT = Alignment.ALIGN_LEFT
ALIGN_CENTER = Alignment.ALIGN_CENTER
ALIGN_RIGHT = Alignment.ALIGN_RIGHT
STYLE_DEFAULT = Style.STYLE_DEFAULT
STYLE_NONE = Style.STYLE_NONE
STYLE_DOTTED = Style.STYLE_DOTTED
STYLE_SEPARATED = Style.STYLE_SEPARATED
STYLE_COMPACT = Style.STYLE_COMPACT
STYLE_MYSQL = Style.STYLE_MYSQL
STYLE_MARKDOWN = Style.STYLE_MARKDOWN
STYLE_RST = Style.STYLE_RST
STYLE_BOX = Style.STYLE_BOX
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
according to width exceed policy.
        """
        table = self._table
        lpw, rpw = self._get_padding()
        wep = table.columns.width_exceed_policy

        result = []

        if (
            wep is enums.WidthExceedPolicy.WEP_STRIP
            or wep is enums.WidthExceedPolicy.WEP_ELLIPSIS
        ):

            # Let's strip the row
            delimiter = (
                "" if wep is enums.WidthExceedPolicy.WEP_STRIP else "..."
            )
            row_item_list = []
            for index, row_item in enumerate(row):
                left_pad = table.columns._pad_character * lpw[index]
                right_pad = table.columns._pad_character * rpw[index]
                clmp_str = (
                    left_pad
                    + self._clamp_string(row_item, index, delimiter)
                    + right_pad
                )
                row_item_list.append(clmp_str)
            result.append(row_item_list)
        elif wep is enums.WidthExceedPolicy.WEP_WRAP:

            # Let's wrap the row
            string_partition = []