mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
Refs #401 - Fixed some flake8 errors
This commit is contained in:
@@ -7,8 +7,9 @@ setup(
|
||||
use_scm_version=True,
|
||||
setup_requires=['setuptools_scm'],
|
||||
description='Format agnostic tabular data library (XLS, JSON, YAML, CSV)',
|
||||
long_description=(open('README.md').read() + '\n\n' +
|
||||
open('HISTORY.md').read()),
|
||||
long_description=(
|
||||
open('README.md').read() + '\n\n' + open('HISTORY.md').read()
|
||||
),
|
||||
long_description_content_type="text/markdown",
|
||||
author='Kenneth Reitz',
|
||||
author_email='me@kennethreitz.org',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
""" Tablib. """
|
||||
from pkg_resources import DistributionNotFound, get_distribution
|
||||
from tablib.core import (
|
||||
from tablib.core import ( # noqa: F401
|
||||
Databook,
|
||||
Dataset,
|
||||
InvalidDatasetType,
|
||||
|
||||
+1
-2
@@ -12,7 +12,6 @@ from collections import OrderedDict
|
||||
from copy import copy
|
||||
from operator import itemgetter
|
||||
|
||||
from tablib import formats
|
||||
from tablib.exceptions import (
|
||||
HeadersNeeded,
|
||||
InvalidDatasetIndex,
|
||||
@@ -416,7 +415,7 @@ class Dataset:
|
||||
fmt = registry.get_format(format)
|
||||
if not hasattr(fmt, 'import_set'):
|
||||
raise UnsupportedFormat('Format {} cannot be imported.'.format(format))
|
||||
|
||||
|
||||
if not import_set:
|
||||
raise UnsupportedFormat('Format {} cannot be imported.'.format(format))
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ODSFormat:
|
||||
try:
|
||||
col = str(col, errors='ignore')
|
||||
except TypeError:
|
||||
## col is already str
|
||||
# col is already str
|
||||
pass
|
||||
ws.addElement(table.TableColumn())
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ class ReSTFormat:
|
||||
lines = [''.join((lpad, pad.join(line), rpad)) for line in lines]
|
||||
return lines
|
||||
|
||||
|
||||
@classmethod
|
||||
def _get_column_widths(cls, dataset, max_table_width=MAX_TABLE_WIDTH, pad_len=3):
|
||||
"""
|
||||
@@ -184,7 +183,6 @@ class ReSTFormat:
|
||||
lines.append(row_sep)
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
@classmethod
|
||||
def _use_simple_table(cls, head0, col0, width0):
|
||||
"""
|
||||
|
||||
@@ -63,7 +63,6 @@ class XLSFormat:
|
||||
wb.save(stream)
|
||||
return stream.getvalue()
|
||||
|
||||
|
||||
@classmethod
|
||||
def import_set(cls, dset, in_stream, headers=True):
|
||||
"""Returns databook from XLS stream."""
|
||||
|
||||
+14
-4
@@ -169,7 +169,8 @@ class TablibTestCase(BaseTestCase):
|
||||
def test_add_callable_column(self):
|
||||
"""Verify adding column with values specified as callable."""
|
||||
|
||||
new_col = lambda x: x[0]
|
||||
def new_col(x):
|
||||
return x[0]
|
||||
|
||||
self.founders.append_col(new_col, header='first_again')
|
||||
|
||||
@@ -1313,10 +1314,19 @@ class DocTests(unittest.TestCase):
|
||||
|
||||
class CliTests(BaseTestCase):
|
||||
def test_cli_export_github(self):
|
||||
self.assertEqual('|---|---|---|\n| a | b | c |', tablib.Dataset(['a','b','c']).export('cli', tablefmt='github'))
|
||||
self.assertEqual(
|
||||
'|---|---|---|\n| a | b | c |',
|
||||
tablib.Dataset(['a', 'b', 'c']).export('cli', tablefmt='github')
|
||||
)
|
||||
|
||||
def test_cli_export_simple(self):
|
||||
self.assertEqual('- - -\na b c\n- - -', tablib.Dataset(['a','b','c']).export('cli', tablefmt='simple'))
|
||||
self.assertEqual(
|
||||
'- - -\na b c\n- - -',
|
||||
tablib.Dataset(['a', 'b', 'c']).export('cli', tablefmt='simple')
|
||||
)
|
||||
|
||||
def test_cli_export_grid(self):
|
||||
self.assertEqual('+---+---+---+\n| a | b | c |\n+---+---+---+', tablib.Dataset(['a','b','c']).export('cli', tablefmt='grid'))
|
||||
self.assertEqual(
|
||||
'+---+---+---+\n| a | b | c |\n+---+---+---+',
|
||||
tablib.Dataset(['a', 'b', 'c']).export('cli', tablefmt='grid')
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user