Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit 88a3c3d

Browse files
committed
[REF] gen_table_bbox: stop processing if all textlines have been processed
1 parent 1b6189c commit 88a3c3d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

camelot/parsers/network.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,12 @@ def _generate_table_bbox(self):
799799
self.parse_details["bbox_searches"] = []
800800
self.parse_details["col_searches"] = []
801801

802-
while True:
802+
while textlines: # Continue while there are textlines to process
803803
bbox_body = None
804804
bbox_body, gaps_hv = self._get_bbox_body(user_provided_bboxes, textlines)
805+
805806
if bbox_body is None:
806-
break
807+
break # Exit the loop if no more bbox_body can be generated
807808

808809
tls_in_bbox = textlines_overlapping_bbox(bbox_body, textlines)
809810
cols_boundaries = find_columns_boundaries(tls_in_bbox)
@@ -836,8 +837,13 @@ def _generate_table_bbox(self):
836837

837838
# Update processed textlines
838839
textlines_processed.update(tls_in_bbox)
840+
# Filter out processed textlines
839841
textlines = [tl for tl in textlines if tl not in textlines_processed]
840842

843+
# Early exit if all textlines have been processed
844+
if not textlines:
845+
break # No more textlines to process, exit the loop
846+
841847
def _get_bbox_body(self, user_provided_bboxes, textlines):
842848
if user_provided_bboxes is not None:
843849
if len(user_provided_bboxes) > 0:

0 commit comments

Comments
 (0)