From 0d6a2ba55443e1c3422a34825f4403111e1dc45e Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 9 Jul 2018 14:28:37 -0700 Subject: [PATCH] Declare certain APIs public --- docs/release_notes.rst | 8 ++++++-- src/ocrmypdf/__init__.py | 13 +++++++++++++ src/ocrmypdf/__main__.py | 2 +- src/ocrmypdf/{pipeline.py => _pipeline.py} | 0 4 files changed, 20 insertions(+), 3 deletions(-) rename src/ocrmypdf/{pipeline.py => _pipeline.py} (100%) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 0acc5089..62890229 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -1,9 +1,13 @@ Release notes ============= -OCRmyPDF uses `semantic versioning `_ for its command line interface. +OCRmyPDF uses `semantic versioning `_ for its command line interface and its public API. -The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. +The ``ocrmypdf`` package may now be imported. The public API may be useful in scripts that launch OCRmyPDF processes or that wish to use some of its features for working with PDFs. + +Unfortunately, the public API does **not** expose the ability to actually OCR a PDF. This is due to a limitation in an underlying library (ruffus) that makes OCRmyPDF non-reentrant. + +Note that it is licensed under GPLv3, so scripts that ``import ocrmypdf`` and are released publicly should probably also be licensed under GPLv3. .. Issue regex find: [^`]\#([0-9]{1,3})[^0-9] diff --git a/src/ocrmypdf/__init__.py b/src/ocrmypdf/__init__.py index 3f534ab9..eff86707 100644 --- a/src/ocrmypdf/__init__.py +++ b/src/ocrmypdf/__init__.py @@ -23,3 +23,16 @@ PROGRAM_NAME = 'ocrmypdf' __version__ = pkg_resources.get_distribution('ocrmypdf').version VERSION = __version__ + +from .exceptions import ( + ExitCode, BadArgsError, PdfMergeFailedError, MissingDependencyError, + UnsupportedImageFormatError, DpiError, OutputFileAccessError, + PriorOcrFoundError, InputFileError, SubprocessOutputError, + EncryptedPdfError, TesseractConfigError +) + +from . import helpers +from . import hocrtransform +from . import leptonica +from . import pdfa +from . import pdfinfo diff --git a/src/ocrmypdf/__main__.py b/src/ocrmypdf/__main__.py index fda79bbc..bcc094ad 100755 --- a/src/ocrmypdf/__main__.py +++ b/src/ocrmypdf/__main__.py @@ -34,7 +34,7 @@ import ruffus.cmdline as cmdline import ruffus.proxy_logger as proxy_logger from ._jobcontext import JobContext, JobContextManager, cleanup_working_files -from .pipeline import build_pipeline +from ._pipeline import build_pipeline from .pdfa import file_claims_pdfa from .helpers import is_iterable_notstr, re_symlink, is_file_writable, \ available_cpu_count diff --git a/src/ocrmypdf/pipeline.py b/src/ocrmypdf/_pipeline.py similarity index 100% rename from src/ocrmypdf/pipeline.py rename to src/ocrmypdf/_pipeline.py