Date: Thu, 27 Jan 2022 23:50:30 GMT From: Matthias Andree <mandree@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: fb684eef543b - main - graphics/py-pytesseract: fix DICT conversion Message-ID: <202201272350.20RNoUPd000811@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mandree: URL: https://cgit.FreeBSD.org/ports/commit/?id=fb684eef543b0c451ac9a59e50ee40ee540241f3 commit fb684eef543b0c451ac9a59e50ee40ee540241f3 Author: Matthias Andree <mandree@FreeBSD.org> AuthorDate: 2022-01-27 23:48:12 +0000 Commit: Matthias Andree <mandree@FreeBSD.org> CommitDate: 2022-01-27 23:50:17 +0000 graphics/py-pytesseract: fix DICT conversion ...via tsv file; this was the one failing self-test, now passes. https://github.com/madmaze/pytesseract/issues/406 --- graphics/py-pytesseract/Makefile | 5 +++- graphics/py-pytesseract/files/patch-g06e7f807 | 36 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) 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,5 +1,6 @@ PORTNAME= pytesseract PORTVERSION= 0.3.9 +PORTREVISION= 1 DISTVERSIONPREFIX= v CATEGORIES= graphics python PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} @@ -7,6 +8,8 @@ PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} MAINTAINER= mandree@FreeBSD.org COMMENT= wrapper for Google's Tesseract OCR engine +PATCH_STRIP= -p1 + LICENSE= BSD2CLAUSE LICENSE_FILE= ${WRKSRC}/LICENSE @@ -25,7 +28,7 @@ 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 <bsd.port.pre.mk> 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 <int3l@users.noreply.github.com> +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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201272350.20RNoUPd000811>