From a0bee44f6428dd34e50afeddbefbc9840fbb1f83 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Sun, 8 Sep 2024 11:27:10 -0700 Subject: [PATCH] Rework logic again for testing --- src/paperless_tesseract/checks.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/paperless_tesseract/checks.py b/src/paperless_tesseract/checks.py index 8e729d797..0d7a1d90d 100644 --- a/src/paperless_tesseract/checks.py +++ b/src/paperless_tesseract/checks.py @@ -21,29 +21,32 @@ def get_tesseract_langs(): @register() def check_default_language_available(app_configs, **kwargs): + errs = [] + + if not settings.OCR_LANGUAGE: + errs.append( + Warning( + "No OCR language has been specified with PAPERLESS_OCR_LANGUAGE. " + "This means that tesseract will fallback to english.", + ), + ) + return errs + # binaries_check in paperless will check and report if this doesn't exist # So skip trying to do anything here and let that handle missing binaries if shutil.which("tesseract") is not None: installed_langs = get_tesseract_langs() - specified_langs = settings.OCR_LANGUAGE.split("+") + specified_langs = [x.strip() for x in settings.OCR_LANGUAGE.split("+")] for lang in specified_langs: if lang not in installed_langs: - return [ + errs.append( Error( f"The selected ocr language {lang} is " f"not installed. Paperless cannot OCR your documents " f"without it. Please fix PAPERLESS_OCR_LANGUAGE.", ), - ] + ) - if not settings.OCR_LANGUAGE: - return [ - Warning( - "No OCR language has been specified with PAPERLESS_OCR_LANGUAGE. " - "This means that tesseract will fallback to english.", - ), - ] - - return [] + return errs