From 8ab947a44c96cd5dfcfd16c59d5d29d3e52fd4c7 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 5 Jun 2026 14:39:59 +0100 Subject: [PATCH] src/table.py: be stricter with USE_TGIF. We now raise if USE_TGIF has an unexpected value. --- src/table.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/table.py b/src/table.py index ee887fd94..39ce02f95 100644 --- a/src/table.py +++ b/src/table.py @@ -96,7 +96,10 @@ # This replace fz_find_table_within_bounds. USE_TGIF = os.getenv("USE_TGIF", "0") EXTRACTOR_V4 = None # Keep pylint happy. -if USE_TGIF == "1": +if USE_TGIF == "0": + if os.environ.get('PYMUPDF_LEGACY_TABLE_DIAGNOSTIC') != '0': + print("Using legacy table grid extraction.") +elif USE_TGIF == "1": print("Using TGIFVx for table grid extraction.") import pymupdf.tgif # pylint: disable=import-error elif USE_TGIF == "4": @@ -113,8 +116,7 @@ # filter_empty_lines=not args.no_filter_empty, ) else: - if os.environ.get('PYMUPDF_LEGACY_TABLE_DIAGNOSTIC') != '0': - print("Using legacy table grid extraction.") + raise Exception(f"Unrecognised {USE_TGIF=}, should be unset, '0', '1' or '4'.") EDGES = [] # vector graphics from PyMuPDF CHARS = [] # text characters from PyMuPDF