Remove "from ocrmypdf import ocrmypdf"

Messes up future imports from ocrmypdf, so don't do it.
This commit is contained in:
James R. Barlow
2019-06-12 17:52:25 -07:00
parent cfb11559d5
commit 16990890d8
7 changed files with 18 additions and 16 deletions
+5 -5
View File
@@ -12,9 +12,9 @@ OCRmyPDF one high-level function to run its main engine from an application. The
.. code-block:: python
from ocrmypdf import ocrmypdf
import ocrmypdf
ocrmypdf('input.pdf', 'output.pdf', deskew=True)
ocrmypdf.run('input.pdf', 'output.pdf', deskew=True)
With a few exceptions, all of the command line arguments are available and may be passed as equivalent keywords.
@@ -29,11 +29,11 @@ The :func:`ocrmypdf.ocrmypdf` function runs OCRmyPDF similar to command line exe
- manage the signal flags of worker processes
0 execute other subprocesses (forking and executing other programs)
The Python process that calls ``ocrmypdf()`` must be sufficiently privileged to perform these actions. If it is not, ``ocrmypdf()`` will fail.
The Python process that calls ``ocrmypdf.run()`` must be sufficiently privileged to perform these actions. If it is not, ``ocrmypdf()`` will fail.
There is no currently no option to manage how jobs are scheduled other than the argument ``jobs=`` which will limit the number of worker processes.
Forking a child process to call ``ocrmypdf()`` is suggested. That way your application will survive even if OCRmyPDF does not.
Forking a child process to call ``ocrmypdf.run()`` is suggested. That way your application will survive even if OCRmyPDF does not.
Logging
^^^^^^^
@@ -59,7 +59,7 @@ When OCRmyPDF succeeds conditionally, it may return an integer exit code.
Reference
---------
.. autofunction:: ocrmypdf.ocrmypdf
.. autofunction:: ocrmypdf.run
.. autoclass:: ocrmypdf.Verbosity
:members:
+1 -1
View File
@@ -44,4 +44,4 @@ from . import hocrtransform
from . import leptonica
from . import pdfa
from . import pdfinfo
from .api import ocrmypdf, configure_logging, Verbosity
from .api import run, configure_logging, Verbosity
+1 -1
View File
@@ -158,7 +158,7 @@ def create_options(*, input_file, output_file, **kwargs):
return options
def ocrmypdf( # pylint: disable=unused-argument
def run( # pylint: disable=unused-argument
input_file,
output_file,
*,
+2 -2
View File
@@ -21,7 +21,7 @@ from PIL import Image
import pytest
from ocrmypdf import ocrmypdf
import ocrmypdf
from ocrmypdf.filters import invert, whiteout
from ocrmypdf._plugins import load_plugin
@@ -80,7 +80,7 @@ def test_filter_from_cmdline(resources, outdir):
def test_filter_from_api(resources, outdir):
ocrmypdf(
ocrmypdf.run(
resources / 'crom.png',
outdir / 'out.pdf',
image_dpi=100,
+4 -2
View File
@@ -27,7 +27,7 @@ import PIL
import pytest
from PIL import Image
from ocrmypdf import ocrmypdf
import ocrmypdf
from ocrmypdf.exceptions import ExitCode, MissingDependencyError
from ocrmypdf.exec import ghostscript, qpdf, tesseract
from ocrmypdf.leptonica import Pix
@@ -614,7 +614,9 @@ def test_closed_streams(spoof_tesseract_noop, ocrmypdf_exec, resources, outpdf):
def test_masks(spoof_tesseract_noop, resources, outpdf):
assert (
ocrmypdf(resources / 'masks.pdf', outpdf, tesseract_env=spoof_tesseract_noop)
ocrmypdf.run(
resources / 'masks.pdf', outpdf, tesseract_env=spoof_tesseract_noop
)
== ExitCode.ok
)
+2 -2
View File
@@ -17,7 +17,7 @@
import pytest
from ocrmypdf import ocrmypdf as run
import ocrmypdf
from ocrmypdf._validation import _pages_from_ranges
from ocrmypdf.pdfinfo import PdfInfo
@@ -42,7 +42,7 @@ def test_list_range():
def test_limited_pages(resources, outpdf, spoof_tesseract_cache):
multi = resources / 'multipage.pdf'
run(
ocrmypdf.run(
multi,
outpdf,
pages='5-6',
+3 -3
View File
@@ -19,7 +19,7 @@ import os
import pytest
from ocrmypdf import ocrmypdf
import ocrmypdf
import pikepdf
os_environ = pytest.helpers.os_environ
@@ -36,14 +36,14 @@ def test_no_glyphless_weave(resources, outdir):
env = os.environ.copy()
env['_OCRMYPDF_MAX_REPLACE_PAGES'] = '2'
with os_environ(env):
ocrmypdf(
ocrmypdf.run(
outdir / 'test.pdf', outdir / 'out.pdf', deskew=True, tesseract_timeout=0
)
@pytest.helpers.needs_pdfminer
def test_links(resources, outpdf):
ocrmypdf(
ocrmypdf.run(
resources / 'link.pdf', outpdf, redo_ocr=True, oversample=200, output_type='pdf'
)
pdf = pikepdf.open(outpdf)