v0.5.6
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
"""Route table/listing continuation post-processing to Word or UNO backends."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ..word_fix import FixResult, fix_continuations
|
||||
from .detect import DEFAULT_OFFICE_ENGINE, resolve_office_engine
|
||||
from .uno_fix import fix_continuations_uno
|
||||
|
||||
|
||||
def fix_continuations_with_engine(
|
||||
path: str,
|
||||
*,
|
||||
engine: str = DEFAULT_OFFICE_ENGINE,
|
||||
tables: bool = True,
|
||||
listings: bool = True,
|
||||
repeat_header: bool = False,
|
||||
) -> FixResult:
|
||||
"""
|
||||
Split cross-page tables/listings using the selected office engine.
|
||||
|
||||
``engine`` is ``auto|word|libre|openoffice``. On missing backend returns
|
||||
``ok=False`` with a reason; conversion should continue.
|
||||
"""
|
||||
resolved, install = resolve_office_engine(engine)
|
||||
if resolved is None or install is None:
|
||||
if engine == "auto":
|
||||
return FixResult(
|
||||
False,
|
||||
message=(
|
||||
"Пост-разрыв таблиц пропущен: не найден Word, LibreOffice "
|
||||
"или OpenOffice."
|
||||
),
|
||||
)
|
||||
labels = {
|
||||
"word": "Microsoft Word (Windows + pywin32)",
|
||||
"libre": "LibreOffice (soffice + program/python)",
|
||||
"openoffice": "OpenOffice (soffice + program/python)",
|
||||
}
|
||||
return FixResult(
|
||||
False,
|
||||
message=f"Пост-разрыв таблиц пропущен: нужен {labels.get(engine, engine)}.",
|
||||
)
|
||||
|
||||
if resolved == "word":
|
||||
return fix_continuations(
|
||||
path,
|
||||
tables=tables,
|
||||
listings=listings,
|
||||
repeat_header=repeat_header,
|
||||
)
|
||||
|
||||
assert install.soffice_path and install.python_path
|
||||
return fix_continuations_uno(
|
||||
path,
|
||||
install=install,
|
||||
tables=tables,
|
||||
listings=listings,
|
||||
repeat_header=repeat_header,
|
||||
)
|
||||
Reference in New Issue
Block a user