Split tests for lattice and stream, and fix test_common reprs

This commit is contained in:
Vinayak Mehta
2021-06-28 05:32:48 +05:30
parent 3ddc02b2f2
commit 36dcfe99d8
6 changed files with 314 additions and 234 deletions
+6 -2
View File
@@ -23,7 +23,9 @@ class ImageConversionBackend(object):
converter = backends[self.backend]()
converter.convert(pdf_path, png_path)
except Exception as e:
logger.info(f"Image conversion backend '{self.backend}' failed with '{str(e)}'")
logger.info(
f"Image conversion backend '{self.backend}' failed with '{str(e)}'"
)
if self.use_fallback:
for fallback in self.fallbacks:
@@ -33,7 +35,9 @@ class ImageConversionBackend(object):
converter = backends[fallback]()
converter.convert(pdf_path, png_path)
except Exception as e:
logger.info(f"Image conversion backend '{fallback}' failed with '{str(e)}'")
logger.info(
f"Image conversion backend '{fallback}' failed with '{str(e)}'"
)
continue
else:
logger.info(f"Image conversion backend '{fallback}' succeeded")
+4 -4
View File
@@ -288,10 +288,10 @@ class Cell(object):
self._text = ""
def __repr__(self):
x1 = round(self.x1, 2)
y1 = round(self.y1, 2)
x2 = round(self.x2, 2)
y2 = round(self.y2, 2)
x1 = round(self.x1)
y1 = round(self.y1)
x2 = round(self.x2)
y2 = round(self.y2)
return f"<Cell x1={x1} y1={y1} x2={x2} y2={y2}>"
@property
+2 -1
View File
@@ -112,6 +112,7 @@ class Lattice(BaseParser):
threshold_constant=-2,
iterations=0,
resolution=300,
backend=ImageConversionBackend(),
**kwargs,
):
self.table_regions = table_regions
@@ -129,7 +130,7 @@ class Lattice(BaseParser):
self.threshold_constant = threshold_constant
self.iterations = iterations
self.resolution = resolution
self.backend = ImageConversionBackend()
self.backend = backend
@staticmethod
def _reduce_index(t, idx, shift_text):