Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return lambda self, value: setattr(
self, attr, ensure_type(value, basestring)
)
def separator(self, value):
self._table._header_separator = ensure_type(value, basestring)
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__
)
def __setitem__(self, key, value): # pragma: no cover
if isinstance(key, basestring):
self.columns[key] = value
else:
self.rows[key] = value
def validate(self, value):
if not isinstance(value, basestring):
raise TypeError(
("header must be of type 'str', " "got {}").format(
type(value).__name__
)
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(