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