Enforce configurable height and pixel limits for tablet documents

This commit is contained in:
sebastien committed 2026-10-26 15:09:05 +01:00
1 parent 8918d64452
commit a38c1ff4b3
10 files changed
+187 -57

No files matched your search

+8 -1
View File
@@ -1,12 +1,19 @@
"""Locate tablet documents, including the parts of a large checked copy."""
from pathlib import Path
from copienator.configuration import ANNOTATION_MAX_HEIGHT_PX
from copienator.configuration import ANNOTATION_MAX_HEIGHT_PX, ANNOTATION_MAX_PIXELS
from copienator.json_io import read_json
if type(ANNOTATION_MAX_HEIGHT_PX) is not int or ANNOTATION_MAX_HEIGHT_PX <= 0:
raise ValueError("ANNOTATION_MAX_HEIGHT_PX must be a positive integer (pixels)")
MAX_HEIGHT_PX = ANNOTATION_MAX_HEIGHT_PX
if type(ANNOTATION_MAX_PIXELS) is not int or ANNOTATION_MAX_PIXELS <= 0:
raise ValueError("ANNOTATION_MAX_PIXELS must be a positive integer (pixels)")
MAX_PIXELS = ANNOTATION_MAX_PIXELS
def document_fits(width: int, height: int, max_height: int, max_pixels: int) -> bool:
return height <= max_height and width * height <= max_pixels
def copy_documents(directory: Path) -> list[Path]: