pull/2/head
Vinayak Mehta 2019-01-03 16:13:41 +05:30
parent 9d90cadac0
commit 605ffdd444
4 changed files with 13 additions and 4 deletions

View File

@ -357,8 +357,8 @@ class Lattice(BaseParser):
if not self.horizontal_text: if not self.horizontal_text:
if self.images: if self.images:
warnings.warn('The page is image-based, Camelot only works with' warnings.warn('{} is image-based, camelot only works on'
' text-based PDF pages.'.format(os.path.basename(self.rootname))) ' text-based pages.'.format(os.path.basename(self.rootname)))
else: else:
warnings.warn('No tables found on {}'.format( warnings.warn('No tables found on {}'.format(
os.path.basename(self.rootname))) os.path.basename(self.rootname)))

View File

@ -396,8 +396,8 @@ class Stream(BaseParser):
if not self.horizontal_text: if not self.horizontal_text:
if self.images: if self.images:
warnings.warn('The page is image-based, Camelot only works with' warnings.warn('{} is image-based, camelot only works on'
' text-based PDF pages.'.format(os.path.basename(self.rootname))) ' text-based pages.'.format(os.path.basename(self.rootname)))
else: else:
warnings.warn('No tables found on {}'.format( warnings.warn('No tables found on {}'.format(
os.path.basename(self.rootname))) os.path.basename(self.rootname)))

Binary file not shown.

View File

@ -41,6 +41,15 @@ def test_stream_equal_length():
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'])
def test_image_warning():
filename = os.path.join(testdir, 'image.pdf')
with warnings.catch_warnings():
warnings.simplefilter('error')
with pytest.raises(UserWarning) as e:
tables = camelot.read_pdf(filename)
assert str(e.value) == 'page-1 is image-based, camelot only works on text-based pages.'
def test_no_tables_found(): def test_no_tables_found():
filename = os.path.join(testdir, 'blank.pdf') filename = os.path.join(testdir, 'blank.pdf')
with warnings.catch_warnings(): with warnings.catch_warnings():