feat: implement plugin option models with backward compatibility
This commit introduces Pydantic models for plugin-specific options in OCRmyPDF, focusing on: - Creating TesseractOptions, OptimizeOptions, and GhostscriptOptions - Adding backward compatibility properties - Maintaining existing CLI and API functionality - Preparing for future plugin option registration system The changes include: - Added type-annotated option models with validation - Updated OCROptions to include legacy fields - Added backward compatibility properties for jbig2 options - Prepared groundwork for dynamic plugin option handling Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
@@ -5,8 +5,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Annotated
|
||||
|
||||
from packaging.version import Version
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from ocrmypdf import hookimpl
|
||||
from ocrmypdf._exec import ghostscript
|
||||
@@ -20,6 +22,13 @@ log = logging.getLogger(__name__)
|
||||
BLACKLISTED_GS_VERSIONS: frozenset[Version] = frozenset()
|
||||
|
||||
|
||||
class GhostscriptOptions(BaseModel):
|
||||
"""Options specific to Ghostscript operations."""
|
||||
|
||||
color_conversion_strategy: Annotated[str, Field(description="Ghostscript color conversion strategy")] = "LeaveColorUnchanged"
|
||||
pdfa_image_compression: Annotated[str, Field(description="PDF/A image compression method")] = "auto"
|
||||
|
||||
|
||||
@hookimpl
|
||||
def add_options(parser):
|
||||
gs = parser.add_argument_group("Ghostscript", "Advanced control of Ghostscript")
|
||||
|
||||
Reference in New Issue
Block a user