How to use the beautifultable.enums.Alignment 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 / helpers.py View on Github external
self.default_padding if padding_right is None else padding_right
        )
        alignment = self.default_alignment if alignment is None else alignment
        if not isinstance(padding_left, int):
            raise TypeError(
                "'padding_left' should be of type 'int' not '{}'".format(
                    type(padding_left).__name__
                )
            )
        if not isinstance(padding_right, int):
            raise TypeError(
                "'padding_right' should be of type 'int' not '{}'".format(
                    type(padding_right).__name__
                )
            )
        if not isinstance(alignment, enums.Alignment):
            raise TypeError(
                "alignment should be of type '{}' not '{}'".format(
                    enums.Alignment.__name__, type(alignment).__name__
                )
            )

        if self._table._ncol == 0:
            self.header = [header]
            self.padding_left = [padding_left]
            self.padding_right = [padding_right]
            self.alignment = [alignment]
            self._table._data = [BTRowData(self._table, [i]) for i in column]
        else:
            if (not isinstance(header, basestring)) and (header is not None):
                raise TypeError(
                    "header must be of type 'str' not '{}'".format(
github pri22296 / beautifultable / beautifultable / meta.py View on Github external
def validate(self, value):
        if not isinstance(value, Alignment):
            allowed = (
                "{}.{}".format(type(self).__name__, i.name) for i in Alignment
            )
            error_msg = (
                "allowed values for alignment are: "
                + ", ".join(allowed)
                + ", was {}".format(value)
            )
            raise TypeError(error_msg)
github pri22296 / beautifultable / beautifultable / enums.py View on Github external
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
STYLE_BOX_ROUNDED = Style.STYLE_BOX_ROUNDED
STYLE_GRID = Style.STYLE_GRID
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
def default_alignment(self, value):
        if not isinstance(value, enums.Alignment):
            allowed = (
                "{}.{}".format(type(self).__name__, i.name)
                for i in enums.Alignment
            )
            error_msg = (
                "allowed values for default_alignment are: "
                + ", ".join(allowed)
            )
            raise ValueError(error_msg)
        self._default_alignment = value
github pri22296 / beautifultable / beautifultable / enums.py View on Github external
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
STYLE_BOX_ROUNDED = Style.STYLE_BOX_ROUNDED
STYLE_GRID = Style.STYLE_GRID
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
if not isinstance(padding_left, int):
            raise TypeError(
                "'padding_left' should be of type 'int' not '{}'".format(
                    type(padding_left).__name__
                )
            )
        if not isinstance(padding_right, int):
            raise TypeError(
                "'padding_right' should be of type 'int' not '{}'".format(
                    type(padding_right).__name__
                )
            )
        if not isinstance(alignment, enums.Alignment):
            raise TypeError(
                "alignment should be of type '{}' not '{}'".format(
                    enums.Alignment.__name__, type(alignment).__name__
                )
            )

        if self._table._ncol == 0:
            self.header = [header]
            self.padding_left = [padding_left]
            self.padding_right = [padding_right]
            self.alignment = [alignment]
            self._table._data = [BTRowData(self._table, [i]) for i in column]
        else:
            if (not isinstance(header, basestring)) and (header is not None):
                raise TypeError(
                    "header must be of type 'str' not '{}'".format(
                        type(header).__name__
                    )
                )
github pri22296 / beautifultable / beautifultable / enums.py View on Github external
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
STYLE_BOX_ROUNDED = Style.STYLE_BOX_ROUNDED
STYLE_GRID = Style.STYLE_GRID