From 455e563c402c820966724bb1f61271fdb41c929d Mon Sep 17 00:00:00 2001 From: xxmistacruzxx Date: Thu, 29 Feb 2024 23:12:12 -0500 Subject: [PATCH] Added path setting for Tesseract. Removed printing in getContext function. --- src/alttext/alttext.py | 3 --- src/alttext/ocrengine/tesseract.py | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/alttext/alttext.py b/src/alttext/alttext.py index b9958a7..9fd644d 100644 --- a/src/alttext/alttext.py +++ b/src/alttext/alttext.py @@ -516,7 +516,6 @@ class AltTextHTML(AltText): text = elem.text.strip() context[0] = text except: - print("error 0") context[0] = None elem = tag text = "" @@ -527,9 +526,7 @@ class AltTextHTML(AltText): text = elem.text.strip() context[1] = text except: - print("error 1") context[1] = None - print(context) return context def genChars(self, imgData: bytes, src: str) -> str: diff --git a/src/alttext/ocrengine/tesseract.py b/src/alttext/ocrengine/tesseract.py index f42c6c8..6901b20 100644 --- a/src/alttext/ocrengine/tesseract.py +++ b/src/alttext/ocrengine/tesseract.py @@ -5,8 +5,9 @@ import pytesseract from .ocrengine import OCREngine class Tesseract(OCREngine): - def __init__(self) -> None: - self.customPath = None + def __init__(self, path:str = None) -> None: + if (path != None): + self._setTesseract(path) return None def _setTesseract(self, path: str) -> bool: