Replace magic Ghostscript raster device strings with StrEnum
This commit is contained in:
@@ -8,6 +8,7 @@ from __future__ import annotations
|
||||
from abc import ABC, abstractmethod
|
||||
from argparse import ArgumentParser
|
||||
from collections.abc import Sequence, Set
|
||||
from enum import StrEnum
|
||||
from logging import Handler
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, NamedTuple
|
||||
@@ -30,6 +31,18 @@ if TYPE_CHECKING:
|
||||
|
||||
# pylint: enable=ungrouped-imports
|
||||
|
||||
|
||||
class GhostscriptRasterDevice(StrEnum):
|
||||
"""Possible raster devices for Ghostscript."""
|
||||
|
||||
JPEGGRAY = 'jpeggray'
|
||||
JPEGCOLOR = 'jpeg'
|
||||
PNGMONO = 'pngmono'
|
||||
PNGGRAY = 'pnggray'
|
||||
PNG256 = 'png256'
|
||||
PNG16M = 'png16m'
|
||||
|
||||
|
||||
hookspec = pluggy.HookspecMarker('ocrmypdf')
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
@@ -207,7 +220,7 @@ def validate(pdfinfo: PdfInfo, options: OcrOptions) -> None:
|
||||
def rasterize_pdf_page(
|
||||
input_file: Path,
|
||||
output_file: Path,
|
||||
raster_device: str,
|
||||
raster_device: GhostscriptRasterDevice,
|
||||
raster_dpi: Resolution,
|
||||
pageno: int,
|
||||
page_dpi: Resolution | None,
|
||||
|
||||
Reference in New Issue
Block a user