Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 28, 2023
1 parent f321cb3 commit c51aecf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions pytesseract/pytesseract.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def __init__(self):
'ALTO output not supported. Tesseract >= 4.1.0 required',
)


class URLNotSupported(EnvironmentError):
def __init__(self):
super().__init__(
Expand Down Expand Up @@ -217,8 +218,9 @@ def save(image):
with NamedTemporaryFile(prefix='tess_', delete=False) as f:
if isinstance(image, str):
if image.startswith('http:') or image.startswith('https:'):
if get_tesseract_version(cached=True) < TESSERACT_URL_VERSION\
or not has_libcurl(cached=True):
if get_tesseract_version(
cached=True,
) < TESSERACT_URL_VERSION or not has_libcurl(cached=True):
raise URLNotSupported()
yield f.name, image
else:
Expand Down Expand Up @@ -497,7 +499,7 @@ def has_libcurl():
)
except OSError:
raise TesseractNotFoundError()

return 'libcurl' in output.decode(DEFAULT_ENCODING)


Expand Down
2 changes: 1 addition & 1 deletion tests/pytesseract_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
IS_PYTHON_3 = not IS_PYTHON_2

TESSERACT_VERSION = tuple(get_tesseract_version().release) # to skip tests
HAS_LIBCURL = has_libcurl() # to skip tests
HAS_LIBCURL = has_libcurl() # to skip tests

TESTS_DIR = path.dirname(path.abspath(__file__))
DATA_DIR = path.join(TESTS_DIR, 'data')
Expand Down

0 comments on commit c51aecf

Please sign in to comment.