From 25d046ae95d952aee00ed9931a898af72852024f Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Wed, 10 Nov 2021 00:55:23 -0800 Subject: [PATCH] Modernize OrientationConfidence definition --- src/ocrmypdf/pluginspec.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ocrmypdf/pluginspec.py b/src/ocrmypdf/pluginspec.py index 8d485bf1..dc7bfac1 100644 --- a/src/ocrmypdf/pluginspec.py +++ b/src/ocrmypdf/pluginspec.py @@ -7,10 +7,9 @@ from abc import ABC, abstractmethod from argparse import ArgumentParser, Namespace -from collections import namedtuple from logging import Handler from pathlib import Path -from typing import TYPE_CHECKING, AbstractSet, List, Optional +from typing import TYPE_CHECKING, AbstractSet, List, NamedTuple, Optional import pluggy @@ -307,15 +306,18 @@ def filter_pdf_page( """ -OrientationConfidence = namedtuple('OrientationConfidence', ('angle', 'confidence')) -"""Expresses an OCR engine's confidence in page rotation. +class OrientationConfidence(NamedTuple): + """Expresses an OCR engine's confidence in page rotation. -Attributes: - angle (int): The clockwise angle (0, 90, 180, 270) that the page should be - rotated. 0 means no rotation. - confidence (float): How confident the OCR engine is that this the correct - rotation. 0 is not confident, 15 is very confident. Arbitrary units. -""" + Attributes: + angle: The clockwise angle (0, 90, 180, 270) that the page should be + rotated. 0 means no rotation. + confidence: How confident the OCR engine is that this the correct + rotation. 0 is not confident, 15 is very confident. Arbitrary units. + """ + + angle: int + confidence: float class OcrEngine(ABC):