diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6aff93e..d837263 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,4 +52,4 @@ jobs: TOX_TESTENV_PASSENV: PY_COLORS - name: Test pytesseract package installation - run: pip install -U git+${{ github.server_url }}/${{ github.repository }} && pip show pytesseract && python -c 'import pytesseract' + run: pip install -U git+${{ github.server_url }}/${{ github.repository }} && pip show unstructured_pytesseract && python -c 'import unstructured_pytesseract' diff --git a/setup.cfg b/setup.cfg index cdd8405..9b61c92 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] -name = pytesseract -version = attr: pytesseract.__version__ +name = unstructured_pytesseract +version = attr: unstructured_pytesseract.__version__ author = Samuel Hoffstaetter author_email = samuel@hoffstaetter.com maintainer = Matthias Lee @@ -34,7 +34,7 @@ python_requires = >=3.8 [options.entry_points] console_scripts = - pytesseract = pytesseract.pytesseract:main + pytesseract = pytesseract_unstructured.pytesseract:main [options.packages.find] exclude = diff --git a/tests/pytesseract_test.py b/tests/pytesseract_test.py index 52efa2d..01d95e6 100644 --- a/tests/pytesseract_test.py +++ b/tests/pytesseract_test.py @@ -11,23 +11,23 @@ import pytest -from pytesseract import ALTONotSupported -from pytesseract import get_languages -from pytesseract import get_tesseract_version -from pytesseract import image_to_alto_xml -from pytesseract import image_to_boxes -from pytesseract import image_to_data -from pytesseract import image_to_osd -from pytesseract import image_to_pdf_or_hocr -from pytesseract import image_to_string -from pytesseract import Output -from pytesseract import run_and_get_multiple_output -from pytesseract import TesseractNotFoundError -from pytesseract import TSVNotSupported -from pytesseract.pytesseract import file_to_dict -from pytesseract.pytesseract import numpy_installed -from pytesseract.pytesseract import pandas_installed -from pytesseract.pytesseract import prepare +from unstructured_pytesseract import ALTONotSupported +from unstructured_pytesseract import get_languages +from unstructured_pytesseract import get_tesseract_version +from unstructured_pytesseract import image_to_alto_xml +from unstructured_pytesseract import image_to_boxes +from unstructured_pytesseract import image_to_data +from unstructured_pytesseract import image_to_osd +from unstructured_pytesseract import image_to_pdf_or_hocr +from unstructured_pytesseract import image_to_string +from unstructured_pytesseract import Output +from unstructured_pytesseract import run_and_get_multiple_output +from unstructured_pytesseract import TesseractNotFoundError +from unstructured_pytesseract import TSVNotSupported +from unstructured_pytesseract.pytesseract import file_to_dict +from unstructured_pytesseract.pytesseract import numpy_installed +from unstructured_pytesseract.pytesseract import pandas_installed +from unstructured_pytesseract.pytesseract import prepare if numpy_installed: import numpy as np @@ -379,18 +379,21 @@ def test_wrong_prepare_type(obj): ) def test_wrong_tesseract_cmd(monkeypatch, test_file, test_path): """Test wrong or missing tesseract command.""" - import pytesseract + import unstructured_pytesseract - monkeypatch.setattr('pytesseract.pytesseract.tesseract_cmd', test_path) + monkeypatch.setattr( + 'unstructured_pytesseract.pytesseract.tesseract_cmd', + test_path, + ) with pytest.raises(TesseractNotFoundError): - pytesseract.get_languages.__wrapped__() + unstructured_pytesseract.get_languages.__wrapped__() with pytest.raises(TesseractNotFoundError): - pytesseract.get_tesseract_version.__wrapped__() + unstructured_pytesseract.get_tesseract_version.__wrapped__() with pytest.raises(TesseractNotFoundError): - pytesseract.image_to_string(test_file) + unstructured_pytesseract.image_to_string(test_file) def test_main_not_found_cases( @@ -400,10 +403,10 @@ def test_main_not_found_cases( test_invalid_file, ): """Test wrong or missing tesseract command in main.""" - import pytesseract + import unstructured_pytesseract monkeypatch.setattr('sys.argv', ['', test_invalid_file]) - assert pytesseract.pytesseract.main() == 1 + assert unstructured_pytesseract.pytesseract.main() == 1 captured = capsys.readouterr() assert ( 'No such file or directory' in captured.err @@ -411,18 +414,18 @@ def test_main_not_found_cases( ) monkeypatch.setattr( - 'pytesseract.pytesseract.tesseract_cmd', + 'unstructured_pytesseract.pytesseract.tesseract_cmd', 'wrong_tesseract', ) monkeypatch.setattr('sys.argv', ['', test_file]) - assert pytesseract.pytesseract.main() == 1 + assert unstructured_pytesseract.pytesseract.main() == 1 assert ( "wrong_tesseract is not installed or it's not in your PATH. " 'See README file for more information.' in capsys.readouterr().err ) monkeypatch.setattr('sys.argv', ['']) - assert pytesseract.pytesseract.main() == 2 + assert unstructured_pytesseract.pytesseract.main() == 2 assert 'Usage: pytesseract [-l lang] input_file' in capsys.readouterr().err @@ -433,17 +436,17 @@ def test_main_not_found_cases( ) def test_proper_oserror_exception_handling(monkeypatch, test_file, test_path): """ "Test for bubbling up OSError exceptions.""" - import pytesseract + import unstructured_pytesseract monkeypatch.setattr( - 'pytesseract.pytesseract.tesseract_cmd', + 'unstructured_pytesseract.pytesseract.tesseract_cmd', test_path, ) with pytest.raises( TesseractNotFoundError if IS_PYTHON_2 and test_path else OSError, ): - pytesseract.image_to_string(test_file) + unstructured_pytesseract.image_to_string(test_file) DEFAULT_LANGUAGES = ('fra', 'eng', 'osd') diff --git a/pytesseract/__init__.py b/unstructured_pytesseract/__init__.py similarity index 100% rename from pytesseract/__init__.py rename to unstructured_pytesseract/__init__.py diff --git a/pytesseract/pytesseract.py b/unstructured_pytesseract/pytesseract.py similarity index 100% rename from pytesseract/pytesseract.py rename to unstructured_pytesseract/pytesseract.py