diff --git a/graphics/py-pytesseract/Makefile b/graphics/py-pytesseract/Makefile index 969145cc2539..541f47401242 100644 --- a/graphics/py-pytesseract/Makefile +++ b/graphics/py-pytesseract/Makefile @@ -1,36 +1,39 @@ PORTNAME= pytesseract PORTVERSION= 0.3.9 +PORTREVISION= 1 DISTVERSIONPREFIX= v CATEGORIES= graphics python PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} MAINTAINER= mandree@FreeBSD.org COMMENT= wrapper for Google's Tesseract OCR engine +PATCH_STRIP= -p1 + LICENSE= BSD2CLAUSE LICENSE_FILE= ${WRKSRC}/LICENSE RUN_DEPENDS= tesseract:graphics/tesseract \ ${PYTHON_PKGNAMEPREFIX}pillow>0:graphics/py-pillow@${PY_FLAVOR} TEST_DEPENDS= ${RUN_DEPENDS} \ ${PYNUMPY} \ ${PYTHON_PKGNAMEPREFIX}tox>0:devel/py-tox@${PY_FLAVOR} # if py-tox cannot detect py-filelock, be sure to have version 3.4.2_1 of the latter USES= localbase python:3.7+ USE_GITHUB= yes GH_ACCOUNT= madmaze USE_PYTHON= autoplist concurrent distutils NO_ARCH= yes do-test: - cd ${WRKSRC} && ${SETENV} ${TEST_ENV} tox -e ${PY_FLAVOR} --sitepackages + cd ${WRKSRC} && ${SETENV} ${TEST_ENV} tox-${PYTHON_VER} -e ${PY_FLAVOR} --sitepackages .include .if ${PYTHON_REL} >= 30800 TEST_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}pandas>0:math/py-pandas@${PY_FLAVOR} .endif .include diff --git a/graphics/py-pytesseract/files/patch-g06e7f807 b/graphics/py-pytesseract/files/patch-g06e7f807 new file mode 100644 index 000000000000..71ba847a05ff --- /dev/null +++ b/graphics/py-pytesseract/files/patch-g06e7f807 @@ -0,0 +1,36 @@ +This is obtained from upstream and ADDITIONALLY +changes the try: val = int(row[i]) in upstream int3l@github's version +to int(float(row[i])). -- Matthias Andree, mandree@FreeBSD.org + +From 06e7f8077467950d2f4e0f619fb193730c2d2079 Mon Sep 17 00:00:00 2001 +From: int3l +Date: Thu, 27 Jan 2022 16:09:21 +0200 +Subject: [PATCH] Fix confidence conversion from str to int + +Account for negative values. Fixes #406 +--- + pytesseract/pytesseract.py | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/pytesseract/pytesseract.py b/pytesseract/pytesseract.py +index 984b106..e927e80 100644 +--- a/pytesseract/pytesseract.py ++++ b/pytesseract/pytesseract.py +@@ -313,9 +313,14 @@ def file_to_dict(tsv, cell_delimiter, str_col_idx): + if len(row) <= i: + continue + +- val = row[i] +- if row[i].isdigit() and i != str_col_idx: +- val = int(row[i]) ++ if i != str_col_idx: ++ try: ++ val = int(float(row[i])) ++ except ValueError: ++ val = row[i] ++ else: ++ val = row[i] ++ + result[head].append(val) + + return result