[MRG] Add error/warning tests (#113)

* Add unknown flavor test

* Add input kwargs test

* Remove unused utils

* Add unsupported format test

* Add stream unequal tables-columns length test

* Add python3 compat

* Add no tables found test

* Convert util info log to warning
This commit is contained in:
Vinayak Mehta
2018-10-02 19:28:42 +05:30
committed by GitHub
parent f1bf4309ec
commit c5bde5e2ad
13 changed files with 94 additions and 143 deletions
+5 -4
View File
@@ -4,6 +4,7 @@ from __future__ import division
import os
import copy
import logging
import warnings
import subprocess
import numpy as np
@@ -13,12 +14,12 @@ from .base import BaseParser
from ..core import Table
from ..utils import (scale_image, scale_pdf, segments_in_bbox, text_in_bbox,
merge_close_lines, get_table_index, compute_accuracy,
compute_whitespace, setup_logging)
compute_whitespace)
from ..image_processing import (adaptive_threshold, find_lines,
find_table_contours, find_table_joints)
logger = setup_logging(__name__)
logger = logging.getLogger('camelot')
class Lattice(BaseParser):
@@ -305,11 +306,11 @@ class Lattice(BaseParser):
return table
def extract_tables(self, filename):
logger.info('Processing {}'.format(os.path.basename(filename)))
self._generate_layout(filename)
logger.info('Processing {}'.format(os.path.basename(self.rootname)))
if not self.horizontal_text:
logger.info("No tables found on {}".format(
warnings.warn("No tables found on {}".format(
os.path.basename(self.rootname)))
return []
+6 -5
View File
@@ -3,6 +3,7 @@
from __future__ import division
import os
import logging
import warnings
import numpy as np
import pandas as pd
@@ -10,10 +11,10 @@ import pandas as pd
from .base import BaseParser
from ..core import Table
from ..utils import (text_in_bbox, get_table_index, compute_accuracy,
compute_whitespace, setup_logging)
compute_whitespace)
logger = setup_logging(__name__)
logger = logging.getLogger('camelot')
class Stream(BaseParser):
@@ -287,7 +288,7 @@ class Stream(BaseParser):
else:
ncols = max(set(elements), key=elements.count)
if ncols == 1:
logger.info("No tables found on {}".format(
warnings.warn("No tables found on {}".format(
os.path.basename(self.rootname)))
cols = [(t.x0, t.x1) for r in rows_grouped if len(r) == ncols for t in r]
cols = self._merge_columns(sorted(cols), col_close_tol=self.col_close_tol)
@@ -344,11 +345,11 @@ class Stream(BaseParser):
return table
def extract_tables(self, filename):
logger.info('Processing {}'.format(os.path.basename(filename)))
self._generate_layout(filename)
logger.info('Processing {}'.format(os.path.basename(self.rootname)))
if not self.horizontal_text:
logger.info("No tables found on {}".format(
warnings.warn("No tables found on {}".format(
os.path.basename(self.rootname)))
return []