More linting
parent
07e2e1640d
commit
878ef96fa7
|
|
@ -45,7 +45,8 @@ class PlotMethods(object):
|
|||
plot_method = getattr(self, kind)
|
||||
return plot_method(table)
|
||||
|
||||
def text(self, table):
|
||||
@staticmethod
|
||||
def text(table):
|
||||
"""Generates a plot for all text elements present
|
||||
on the PDF page.
|
||||
|
||||
|
|
@ -78,7 +79,8 @@ class PlotMethods(object):
|
|||
ax.imshow(img, extent=(0, table.pdf_size[0], 0, table.pdf_size[1]))
|
||||
return fig
|
||||
|
||||
def grid(self, table):
|
||||
@staticmethod
|
||||
def grid(table):
|
||||
"""Generates a plot for the detected table grids
|
||||
on the PDF page.
|
||||
|
||||
|
|
@ -108,7 +110,8 @@ class PlotMethods(object):
|
|||
ax.imshow(img, extent=(0, table.pdf_size[0], 0, table.pdf_size[1]))
|
||||
return fig
|
||||
|
||||
def contour(self, table):
|
||||
@staticmethod
|
||||
def contour(table):
|
||||
"""Generates a plot for all table boundaries present
|
||||
on the PDF page.
|
||||
|
||||
|
|
@ -161,7 +164,8 @@ class PlotMethods(object):
|
|||
ax.imshow(img, extent=(0, table.pdf_size[0], 0, table.pdf_size[1]))
|
||||
return fig
|
||||
|
||||
def textedge(self, table):
|
||||
@staticmethod
|
||||
def textedge(table):
|
||||
"""Generates a plot for relevant textedges.
|
||||
|
||||
Parameters
|
||||
|
|
@ -196,7 +200,8 @@ class PlotMethods(object):
|
|||
ax.imshow(img, extent=(0, table.pdf_size[0], 0, table.pdf_size[1]))
|
||||
return fig
|
||||
|
||||
def joint(self, table):
|
||||
@staticmethod
|
||||
def joint(table):
|
||||
"""Generates a plot for all line intersections present
|
||||
on the PDF page.
|
||||
|
||||
|
|
@ -223,7 +228,8 @@ class PlotMethods(object):
|
|||
ax.imshow(img)
|
||||
return fig
|
||||
|
||||
def line(self, table):
|
||||
@staticmethod
|
||||
def line(table):
|
||||
"""Generates a plot for all line segments present
|
||||
on the PDF page.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,27 +17,27 @@ def test_unknown_flavor():
|
|||
message = ("Unknown flavor specified."
|
||||
" Use either 'lattice', 'stream', or 'hybrid'")
|
||||
with pytest.raises(NotImplementedError, match=message):
|
||||
tables = camelot.read_pdf(filename, flavor='chocolate')
|
||||
camelot.read_pdf(filename, flavor='chocolate')
|
||||
|
||||
|
||||
def test_input_kwargs():
|
||||
message = "columns cannot be used with flavor='lattice'"
|
||||
with pytest.raises(ValueError, match=message):
|
||||
tables = camelot.read_pdf(filename, columns=['10,20,30,40'])
|
||||
camelot.read_pdf(filename, columns=['10,20,30,40'])
|
||||
|
||||
|
||||
def test_unsupported_format():
|
||||
message = 'File format not supported'
|
||||
filename = os.path.join(testdir, 'foo.csv')
|
||||
with pytest.raises(NotImplementedError, match=message):
|
||||
tables = camelot.read_pdf(filename)
|
||||
camelot.read_pdf(filename)
|
||||
|
||||
|
||||
def test_stream_equal_length():
|
||||
message = ("Length of table_areas and columns"
|
||||
" should be equal")
|
||||
with pytest.raises(ValueError, match=message):
|
||||
tables = camelot.read_pdf(filename, flavor='stream',
|
||||
camelot.read_pdf(filename, flavor='stream',
|
||||
table_areas=['10,20,30,40'], columns=['10,20,30,40', '10,20,30,40'])
|
||||
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ def test_image_warning():
|
|||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('error')
|
||||
with pytest.raises(UserWarning) as e:
|
||||
tables = camelot.read_pdf(filename)
|
||||
camelot.read_pdf(filename)
|
||||
assert str(e.value) == 'page-1 is image-based, camelot only works on text-based pages.'
|
||||
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ def test_no_tables_found():
|
|||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('error')
|
||||
with pytest.raises(UserWarning) as e:
|
||||
tables = camelot.read_pdf(filename)
|
||||
camelot.read_pdf(filename)
|
||||
assert str(e.value) == 'No tables found on page-1'
|
||||
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ def test_no_tables_found_logs_suppressed():
|
|||
# the test should fail if any warning is thrown
|
||||
warnings.simplefilter('error')
|
||||
try:
|
||||
tables = camelot.read_pdf(filename, suppress_stdout=True)
|
||||
camelot.read_pdf(filename, suppress_stdout=True)
|
||||
except Warning as e:
|
||||
warning_text = str(e)
|
||||
pytest.fail('Unexpected warning: {}'.format(warning_text))
|
||||
|
|
@ -77,7 +77,7 @@ def test_no_tables_found_warnings_suppressed():
|
|||
# the test should fail if any warning is thrown
|
||||
warnings.simplefilter('error')
|
||||
try:
|
||||
tables = camelot.read_pdf(filename, suppress_stdout=True)
|
||||
camelot.read_pdf(filename, suppress_stdout=True)
|
||||
except Warning as e:
|
||||
warning_text = str(e)
|
||||
pytest.fail('Unexpected warning: {}'.format(warning_text))
|
||||
|
|
@ -87,11 +87,11 @@ def test_no_password():
|
|||
filename = os.path.join(testdir, 'health_protected.pdf')
|
||||
message = 'file has not been decrypted'
|
||||
with pytest.raises(Exception, match=message):
|
||||
tables = camelot.read_pdf(filename)
|
||||
camelot.read_pdf(filename)
|
||||
|
||||
|
||||
def test_bad_password():
|
||||
filename = os.path.join(testdir, 'health_protected.pdf')
|
||||
message = 'file has not been decrypted'
|
||||
with pytest.raises(Exception, match=message):
|
||||
tables = camelot.read_pdf(filename, password='wrongpass')
|
||||
camelot.read_pdf(filename, password='wrongpass')
|
||||
|
|
|
|||
Loading…
Reference in New Issue