Rework logic again for testing
This commit is contained in:
parent
aabfc32183
commit
a0bee44f64
@ -21,29 +21,32 @@ def get_tesseract_langs():
|
|||||||
|
|
||||||
@register()
|
@register()
|
||||||
def check_default_language_available(app_configs, **kwargs):
|
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
|
# 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
|
# So skip trying to do anything here and let that handle missing binaries
|
||||||
if shutil.which("tesseract") is not None:
|
if shutil.which("tesseract") is not None:
|
||||||
installed_langs = get_tesseract_langs()
|
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:
|
for lang in specified_langs:
|
||||||
if lang not in installed_langs:
|
if lang not in installed_langs:
|
||||||
return [
|
errs.append(
|
||||||
Error(
|
Error(
|
||||||
f"The selected ocr language {lang} is "
|
f"The selected ocr language {lang} is "
|
||||||
f"not installed. Paperless cannot OCR your documents "
|
f"not installed. Paperless cannot OCR your documents "
|
||||||
f"without it. Please fix PAPERLESS_OCR_LANGUAGE.",
|
f"without it. Please fix PAPERLESS_OCR_LANGUAGE.",
|
||||||
),
|
),
|
||||||
]
|
)
|
||||||
|
|
||||||
if not settings.OCR_LANGUAGE:
|
return errs
|
||||||
return [
|
|
||||||
Warning(
|
|
||||||
"No OCR language has been specified with PAPERLESS_OCR_LANGUAGE. "
|
|
||||||
"This means that tesseract will fallback to english.",
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
return []
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user