How to use the beautifultable.enums 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 / beautifultable.py View on Github external
It can be one of the following:

            * beautifultable.STYLE_DEFAULT
            * beautifultable.STYLE_NONE
            * beautifultable.STYLE_DOTTED
            * beautifultable.STYLE_MYSQL
            * beautifultable.STYLE_SEPARATED
            * beautifultable.STYLE_COMPACT
            * beautifultable.STYLE_MARKDOWN
            * beautifultable.STYLE_RESTRUCTURED_TEXT
            * beautifultable.STYLE_BOX
            * beautifultable.STYLE_BOX_DOUBLED
            * beautifultable.STYLE_BOX_ROUNDED
            * beautifultable.STYLE_GRID
        """
        if not isinstance(style, enums.Style):
            allowed = (
                "{}.{}".format(type(self).__name__, i.name)
                for i in enums.Style
            )
            error_msg = "allowed values for style are: " + ", ".join(allowed)
            raise ValueError(error_msg)
        style_template = style.value
        self.border.left = style_template.left_border_char
        self.border.right = style_template.right_border_char
        self.border.top = style_template.top_border_char
        self.border.bottom = style_template.bottom_border_char

        self.border.top_left = style_template.intersect_top_left
        self.border.bottom_left = style_template.intersect_bottom_left
        self.border.bottom_right = style_template.intersect_bottom_right
        self.border.top_right = style_template.intersect_top_right
github pri22296 / beautifultable / beautifultable / __init__.py View on Github external
__all__ = __all__ + [
    "__title__",
    "__description__",
    "__url__",
    "__version__",
    "__copyright__",
    "__author__",
    "__author_email__",
    "__license__",
]


# To avoid duplicating enums name, dynamically add them to BeautifulTable
# class and __all__
for token in dir(enums):
    if (
        token.startswith("WEP_")
        or token.startswith("ALIGN_")
        or token.startswith("SM_")
        or token.startswith("STYLE_")
    ):
        setattr(BeautifulTable, token, getattr(enums, token))
        __all__.append(token)
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
def alignment(self, value):
        if value is None:
            self._alignment = None
            return
        if isinstance(value, enums.Alignment):
            value = [value] * len(self)
        self._alignment = AlignmentMetaData(self._table, value)
github pri22296 / beautifultable / beautifultable / beautifultable.py View on Github external
def __init__(
        self,
        maxwidth=80,
        default_alignment=enums.ALIGN_CENTER,
        default_padding=1,
        precision=3,
        serialno=False,
        serialno_header="SN",
        detect_numerics=True,
        sign=enums.SM_MINUS,
        **kwargs
    ):

        kwargs.setdefault("max_width", None)
        if kwargs["max_width"] is not None:
            maxwidth = kwargs["max_width"]

        kwargs.setdefault("numeric_precision", None)
        if kwargs["numeric_precision"] is not None:
            precision = kwargs["numeric_precision"]

        kwargs.setdefault("sign_mode", None)
        if kwargs["sign_mode"] is not None:
            sign = kwargs["sign_mode"]

        self.precision = precision
github pri22296 / beautifultable / beautifultable / __init__.py View on Github external
"__author__",
    "__author_email__",
    "__license__",
]


# To avoid duplicating enums name, dynamically add them to BeautifulTable
# class and __all__
for token in dir(enums):
    if (
        token.startswith("WEP_")
        or token.startswith("ALIGN_")
        or token.startswith("SM_")
        or token.startswith("STYLE_")
    ):
        setattr(BeautifulTable, token, getattr(enums, token))
        __all__.append(token)
github pri22296 / beautifultable / beautifultable / beautifultable.py View on Github external
def __init__(
        self,
        maxwidth=80,
        default_alignment=enums.ALIGN_CENTER,
        default_padding=1,
        precision=3,
        serialno=False,
        serialno_header="SN",
        detect_numerics=True,
        sign=enums.SM_MINUS,
        **kwargs
    ):

        kwargs.setdefault("max_width", None)
        if kwargs["max_width"] is not None:
            maxwidth = kwargs["max_width"]

        kwargs.setdefault("numeric_precision", None)
        if kwargs["numeric_precision"] is not None:
            precision = kwargs["numeric_precision"]
github pri22296 / beautifultable / beautifultable / helpers.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 = 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
                )
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
def __init__(self, table, default_alignment, default_padding):
        self._table = table
        self._width_exceed_policy = enums.WEP_WRAP
        self._pad_character = " "
        self.default_alignment = default_alignment
        self.default_padding = default_padding

        self._reset_state(0)