Skip to content

Commit 6b7b67d

Browse files
google-labs-jules[bot]bosd
authored andcommitted
Fix: Replace print with logger.warning for warnings
Replaces the use of `print()` with `logger.warning()` for issuing warnings about unfound bounding boxes. This makes the warnings suppressible and allows for more flexible logging configurations. Fixes #530
1 parent 572db02 commit 6b7b67d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

camelot/parsers/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Defines a base parser. As well as generic methods for other parsers."""
22

3+
import logging
34
import math
45
import os
56
import warnings
@@ -14,6 +15,9 @@
1415
from ..utils import text_in_bbox
1516

1617

18+
logger = logging.getLogger("camelot")
19+
20+
1721
class BaseParser:
1822
"""Defines a base parser."""
1923

@@ -251,10 +255,10 @@ def record_parse_metadata(self, table):
251255
# Handle the KeyError gracefully by returning empty lists
252256
# or by performing alternative logic, such as using a default
253257
# bounding box or skipping the table.
254-
print(
255-
f"Warning: Bounding box {table._bbox} not found in table_bbox_parses."
258+
logger.warning(
259+
f"Bounding box {table._bbox} not found in table_bbox_parses."
256260
)
257-
return [], [], [], [] # Return empty lists for cols, rows, v_s, h_s
261+
return
258262
table.parse_details = self.parse_details
259263
pos_errors = self.compute_parse_errors(table)
260264
table.accuracy = compute_accuracy([[100, pos_errors]])

0 commit comments

Comments
 (0)