Split ocrmypdf.subprocess/__init__.py into three private submodules by concern (_run, _version, _check) and reduce __init__ to re-exports. Introduce ocrmypdf._exec._probe.ToolProbe to centralize the version()/ available() pattern each tool module was reimplementing, so the "is this tool installed and suitable?" question is cleanly distinct from the pure, picklable functions that do the work. Also replace the ghostscript module-import log.addFilter() side effect with an idempotent _ensure_log_filter_installed() called at the top of each work function, so the DuplicateFilter is present in subprocess workers without relying on import-time ordering. Public API of ocrmypdf.subprocess is unchanged.
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
# SPDX-FileCopyrightText: 2022 James R. Barlow
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
"""Wrappers to manage subprocess calls.
|
|
|
|
This package is split into three private submodules by concern:
|
|
|
|
- :mod:`ocrmypdf.subprocess._run` - low-level execution wrappers (``run``,
|
|
``run_polling_stderr``) that add OCRmyPDF-aware logging and Windows PATH
|
|
resolution. Useful as drop-in replacements for :func:`subprocess.run`.
|
|
- :mod:`ocrmypdf.subprocess._version` - version probing (``get_version``).
|
|
- :mod:`ocrmypdf.subprocess._check` - startup validation
|
|
(``check_external_program``) with platform-aware error messages.
|
|
|
|
The names below are the stable public API. Importing from the private
|
|
submodules directly is not supported for external code.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from ocrmypdf.subprocess._check import check_external_program
|
|
from ocrmypdf.subprocess._run import Args, Environ, run, run_polling_stderr
|
|
from ocrmypdf.subprocess._version import get_version
|
|
|
|
__all__ = [
|
|
'Args',
|
|
'Environ',
|
|
'check_external_program',
|
|
'get_version',
|
|
'run',
|
|
'run_polling_stderr',
|
|
]
|