How to use the beautifultable.compat.basestring 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
return lambda self, value: setattr(
        self, attr, ensure_type(value, basestring)
    )
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
def separator(self, value):
        self._table._header_separator = ensure_type(value, basestring)
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
def _validate_item(self, value):
        if not (isinstance(value, basestring) or value is None):
            raise TypeError(
                ("header must be of type 'str', " "got {}").format(
                    type(value).__name__
                )
github pri22296 / beautifultable / beautifultable / beautifultable.py View on Github external
def __setitem__(self, key, value):  # pragma: no cover
        if isinstance(key, basestring):
            self.columns[key] = value
        else:
            self.rows[key] = value
github pri22296 / beautifultable / beautifultable / rows.py View on Github external
def validate(self, value):
        if not isinstance(value, basestring):
            raise TypeError(
                ("header must be of type 'str', " "got {}").format(
                    type(value).__name__
                )
github pri22296 / beautifultable / beautifultable / helpers.py View on Github external
key : int, slice, str
            If key is an `int`, deletes column at index `key`.
            If key is a slice object, deletes multiple columns.
            If key is an `str`, deletes the first column with heading `key`

        Raises
        ------

        TypeError
            If key is not of type int, slice or str.
        IndexError
            If `int` key is out of range.
        KeyError
            If `str` key is not in header.
        """
        if isinstance(key, (int, basestring, slice)):
            key = self._canonical_key(key)

            del self.alignment[key]
            del self.width[key]
            del self.padding_left[key]
            del self.padding_right[key]
            for row in self._table.rows:
                del row[key]
            del self.header[key]
            if self.header.alignment is not None:
                del self.header.alignment[key]
            self._table._ncol = len(self.header)
            if self._table._ncol == 0:
                del self._table.rows[:]
        else:
            raise TypeError(