How to use the ocrmypdf.exec.tesseract.languages function in ocrmypdf

To help you get started, we’ve selected a few ocrmypdf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jbarlow83 / OCRmyPDF / tests / test_main.py View on Github external
# Produce a sidecar too - implicit test that system locale is set up
    # properly. It is fine that we are testing -l deu on a French file because
    # we are exercising the functionality not going for accuracy.
    sidecar = outdir / 'francais.txt'
    try:
        check_ocrmypdf(
            resources / 'francais.pdf',
            outdir / 'francais.pdf',
            '-l',
            'deu',  # more commonly installed
            '--sidecar',
            sidecar,
            env=spoof_tesseract_cache,
        )
    except MissingDependencyError:
        if 'deu' not in tesseract.languages():
            pytest.xfail(reason="tesseract-deu language pack not installed")
        raise
github jbarlow83 / OCRmyPDF / tests / test_tess4.py View on Github external
def test_no_languages(tmp_path):
    env = os.environ.copy()
    (tmp_path / 'tessdata').mkdir()
    env['TESSDATA_PREFIX'] = fspath(tmp_path)

    with pytest.raises(MissingDependencyError):
        tesseract.languages(tesseract_env=env)