From 03ab5a8ee222ee8ebcd76a3f272ec1440fa99766 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 8 Feb 2019 13:04:48 -0800 Subject: [PATCH] If --tesseract-timeout 0, say nothing when we time out This is our "don't actually OCR" mode. No need to mention it. --- src/ocrmypdf/exec/tesseract.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ocrmypdf/exec/tesseract.py b/src/ocrmypdf/exec/tesseract.py index d46c4238..b788d29b 100644 --- a/src/ocrmypdf/exec/tesseract.py +++ b/src/ocrmypdf/exec/tesseract.py @@ -200,7 +200,9 @@ def tesseract_log_output(log, stdout, input_file): log.info(prefix + line.strip()) -def page_timedout(log, input_file): +def page_timedout(log, input_file, timeout): + if timeout == 0: + return prefix = f"{(page_number(input_file)):4d}: [tesseract] " log.warning(prefix + " took too long to OCR - skipping") @@ -257,7 +259,7 @@ def generate_hocr( # Generate a HOCR file with no recognized text if tesseract times out # Temporary workaround to hocrTransform not being able to function if # it does not have a valid hOCR file. - page_timedout(log, input_file) + page_timedout(log, input_file, timeout) _generate_null_hocr(output_hocr, output_sidecar, input_file) except CalledProcessError as e: tesseract_log_output(log, e.output, input_file)