diff options
author | Claude Paroz <claude@2xlibre.net> | 2019-10-03 20:54:10 +0200 |
---|---|---|
committer | Claude Paroz <claude@2xlibre.net> | 2019-10-03 20:54:10 +0200 |
commit | a0d19a56cbb49efbab8497f9eb89b3d6edde91e2 (patch) | |
tree | c356f4c36fc9630a4d927bc828b5b017548b6c64 | |
parent | 8cc024e61b8ad277689485c6bbead9351dfaaada (diff) | |
download | tablib-a0d19a56cbb49efbab8497f9eb89b3d6edde91e2.tar.gz |
Made blank lines PEP-8 compatible
-rw-r--r-- | docs/conf.py | 1 | ||||
-rw-r--r-- | tablib/core.py | 54 | ||||
-rw-r--r-- | tablib/formats/_ods.py | 1 | ||||
-rw-r--r-- | tablib/formats/_xls.py | 2 | ||||
-rw-r--r-- | tablib/formats/_xlsx.py | 1 | ||||
-rw-r--r-- | tablib/packages/dbfpy3/fields.py | 1 |
6 files changed, 4 insertions, 56 deletions
diff --git a/docs/conf.py b/docs/conf.py index 1642931..c38dd06 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -199,7 +199,6 @@ latex_use_parts = True latex_additional_files = ['krstyle.sty'] - # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None diff --git a/tablib/core.py b/tablib/core.py index 6432469..05687a2 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -106,8 +106,6 @@ class Row(object): return bool(len(set(tag) & set(self.tags))) - - class Dataset(object): """The :class:`Dataset` object is the heart of Tablib. It provides all core functionality. @@ -173,11 +171,9 @@ class Dataset(object): self._register_formats() - def __len__(self): return self.height - def __getitem__(self, key): if isinstance(key, (str, unicode)): if key in self.headers: @@ -196,7 +192,6 @@ class Dataset(object): self._validate(value) self._data[key] = Row(value) - def __delitem__(self, key): if isinstance(key, (str, unicode)): @@ -214,7 +209,6 @@ class Dataset(object): else: del self._data[key] - def __repr__(self): try: return '<%s dataset>' % (self.title.lower()) @@ -267,7 +261,6 @@ class Dataset(object): except AttributeError: cls._formats[fmt.title] = (None, None) - def _validate(self, row=None, col=None, safety=False): """Assures size of every row in dataset is of proper proportions.""" if row: @@ -287,7 +280,6 @@ class Dataset(object): raise InvalidDimensions return False - def _package(self, dicts=True, ordered=True): """Packages Dataset into lists of dictionaries for transmission.""" # TODO: Dicts default to false? @@ -312,7 +304,6 @@ class Dataset(object): except IndexError: raise InvalidDatasetIndex - if self.headers: if dicts: data = [dict_pack(list(zip(self.headers, data_row))) for data_row in _data] @@ -323,8 +314,6 @@ class Dataset(object): return data - - def _get_headers(self): """An *optional* list of strings to be used for header rows and attribute names. @@ -333,7 +322,6 @@ class Dataset(object): """ return self.__headers - def _set_headers(self, collection): """Validating headers setter.""" self._validate(collection) @@ -347,7 +335,6 @@ class Dataset(object): headers = property(_get_headers, _set_headers) - def _get_dict(self): """A native Python representation of the :class:`Dataset` object. If headers have been set, a list of Python dictionaries will be returned. If no headers have been set, @@ -361,7 +348,6 @@ class Dataset(object): """ return self._package() - def _set_dict(self, pickle): """A native Python representation of the Dataset object. If headers have been set, a list of Python dictionaries will be returned. If no headers have been @@ -394,7 +380,6 @@ class Dataset(object): dict = property(_get_dict, _set_dict) - def _clean_col(self, col): """Prepares the given column for insert/append.""" @@ -412,7 +397,6 @@ class Dataset(object): return col - @property def height(self): """The number of rows currently in the :class:`Dataset`. @@ -420,7 +404,6 @@ class Dataset(object): """ return len(self._data) - @property def width(self): """The number of columns currently in the :class:`Dataset`. @@ -435,7 +418,6 @@ class Dataset(object): except TypeError: return 0 - def load(self, in_stream, format=None, **kwargs): """ Import `in_stream` to the :class:`Dataset` object using the `format`. @@ -453,8 +435,6 @@ class Dataset(object): import_set(self, in_stream, **kwargs) return self - - def export(self, format, **kwargs): """ Export :class:`Dataset` object to `format`. @@ -552,7 +532,6 @@ class Dataset(object): """ pass - @property def tsv(): """A TSV representation of the :class:`Dataset` object. The top row will contain @@ -677,7 +656,6 @@ class Dataset(object): self._validate(row) self._data.insert(index, Row(row, tags=tags)) - def rpush(self, row, tags=list()): """Adds a row to the end of the :class:`Dataset`. See :class:`Dataset.insert` for additional documentation. @@ -685,7 +663,6 @@ class Dataset(object): self.insert(self.height, row=row, tags=tags) - def lpush(self, row, tags=list()): """Adds a row to the top of the :class:`Dataset`. See :class:`Dataset.insert` for additional documentation. @@ -693,7 +670,6 @@ class Dataset(object): self.insert(0, row=row, tags=tags) - def append(self, row, tags=list()): """Adds a row to the :class:`Dataset`. See :class:`Dataset.insert` for additional documentation. @@ -709,7 +685,6 @@ class Dataset(object): for row in rows: self.append(row, tags) - def lpop(self): """Removes and returns the first row of the :class:`Dataset`.""" @@ -718,7 +693,6 @@ class Dataset(object): return cache - def rpop(self): """Removes and returns the last row of the :class:`Dataset`.""" @@ -727,13 +701,11 @@ class Dataset(object): return cache - def pop(self): """Removes and returns the last row of the :class:`Dataset`.""" return self.rpop() - # ------- # Columns # ------- @@ -788,7 +760,6 @@ class Dataset(object): self.headers.insert(index, header) - if self.height and self.width: for i, row in enumerate(self._data): @@ -798,8 +769,6 @@ class Dataset(object): else: self._data = [Row([row]) for row in col] - - def rpush_col(self, col, header=None): """Adds a column to the end of the :class:`Dataset`. See :class:`Dataset.insert` for additional documentation. @@ -807,7 +776,6 @@ class Dataset(object): self.insert_col(self.width, col, header=header) - def lpush_col(self, col, header=None): """Adds a column to the top of the :class:`Dataset`. See :class:`Dataset.insert` for additional documentation. @@ -815,14 +783,12 @@ class Dataset(object): self.insert_col(0, col, header=header) - def insert_separator(self, index, text='-'): """Adds a separator to :class:`Dataset` at given index.""" sep = (index, text) self._separators.append(sep) - def append_separator(self, text='-'): """Adds a :ref:`separator <separators>` to the :class:`Dataset`.""" @@ -834,7 +800,6 @@ class Dataset(object): self.insert_separator(index, text) - def append_col(self, col, header=None): """Adds a column to the :class:`Dataset`. See :class:`Dataset.insert_col` for additional documentation. @@ -842,13 +807,11 @@ class Dataset(object): self.rpush_col(col, header) - def get_col(self, index): """Returns the column from the :class:`Dataset` at the given index.""" return [row[index] for row in self._data] - # ---- # Misc # ---- @@ -875,7 +838,6 @@ class Dataset(object): return True - def filter(self, tag): """Returns a new instance of the :class:`Dataset`, excluding any rows that do not contain the given :ref:`tags <tags>`. @@ -885,7 +847,6 @@ class Dataset(object): return _dset - def sort(self, col, reverse=False): """Sort a :class:`Dataset` by a specific column, given string (for header) or integer (for column index). The order can be reversed by @@ -921,10 +882,8 @@ class Dataset(object): row = item _dset.append(row=row) - return _dset - def transpose(self): """Transpose a :class:`Dataset`, turning rows into columns and vice versa, returning a new ``Dataset`` instance. The first row of the @@ -953,7 +912,6 @@ class Dataset(object): _dset.append(row=row_data) return _dset - def stack(self, other): """Stack two :class:`Dataset` instances together by joining at the row level, and return new combined @@ -976,7 +934,6 @@ class Dataset(object): return _dset - def stack_cols(self, other): """Stack two :class:`Dataset` instances together by joining at the column level, and return a new @@ -1010,20 +967,17 @@ class Dataset(object): return _dset - def remove_duplicates(self): """Removes all duplicate rows from the :class:`Dataset` object while maintaining the original order.""" seen = set() self._data[:] = [row for row in self._data if not (tuple(row) in seen or seen.add(tuple(row)))] - def wipe(self): """Removes all content and headers from the :class:`Dataset` object.""" self._data = list() self.__headers = None - def subset(self, rows=None, cols=None): """Returns a new instance of the :class:`Dataset`, including only specified rows and columns. @@ -1064,7 +1018,6 @@ class Dataset(object): return _dset - class Databook(object): """A book of :class:`Dataset` objects. """ @@ -1090,7 +1043,6 @@ class Databook(object): """Removes all :class:`Dataset` objects from the :class:`Databook`.""" self._datasets = [] - @classmethod def _register_formats(cls): """Adds format properties.""" @@ -1116,7 +1068,6 @@ class Databook(object): else: raise InvalidDatasetType - def _package(self, ordered=True): """Packages :class:`Databook` for delivery.""" collector = [] @@ -1133,7 +1084,6 @@ class Databook(object): )) return collector - @property def size(self): """The number of the :class:`Dataset` objects within :class:`Databook`.""" @@ -1178,6 +1128,7 @@ def detect_format(stream): except AttributeError: pass + def import_set(stream, format=None, **kwargs): """Return dataset of given stream.""" @@ -1197,11 +1148,14 @@ class InvalidDatasetType(Exception): class InvalidDimensions(Exception): "Invalid size" + class InvalidDatasetIndex(Exception): "Outside of Dataset size" + class HeadersNeeded(Exception): "Header parameter must be given when appending a column in this Dataset." + class UnsupportedFormat(NotImplementedError): "Format is not supported" diff --git a/tablib/formats/_ods.py b/tablib/formats/_ods.py index c7af891..30aea37 100644 --- a/tablib/formats/_ods.py +++ b/tablib/formats/_ods.py @@ -38,7 +38,6 @@ def export_book(databook): wb.spreadsheet.addElement(ws) dset_sheet(dset, ws) - stream = BytesIO() wb.save(stream) return stream.getvalue() diff --git a/tablib/formats/_xls.py b/tablib/formats/_xls.py index 82f8b86..d4d89ae 100644 --- a/tablib/formats/_xls.py +++ b/tablib/formats/_xls.py @@ -61,7 +61,6 @@ def export_book(databook): dset_sheet(dset, ws) - stream = BytesIO() wb.save(stream) return stream.getvalue() @@ -122,7 +121,6 @@ def dset_sheet(dataset, ws): ws.panes_frozen = True ws.horz_split_pos = 1 - # bold separators elif len(row) < dataset.width: ws.write(i, j, col, bold) diff --git a/tablib/formats/_xlsx.py b/tablib/formats/_xlsx.py index 6cbc88b..0099e5e 100644 --- a/tablib/formats/_xlsx.py +++ b/tablib/formats/_xlsx.py @@ -59,7 +59,6 @@ def export_book(databook, freeze_panes=True): dset_sheet(dset, ws, freeze_panes=freeze_panes) - stream = BytesIO() wb.save(stream) return stream.getvalue() diff --git a/tablib/packages/dbfpy3/fields.py b/tablib/packages/dbfpy3/fields.py index 883d035..87916fe 100644 --- a/tablib/packages/dbfpy3/fields.py +++ b/tablib/packages/dbfpy3/fields.py @@ -56,7 +56,6 @@ class DbfFieldDef(object): """ - __slots__ = ("name", "decimalCount", "start", "end", "ignoreErrors") |