Enforce configurable height and pixel limits for tablet documents
This commit is contained in:
1 parent
8918d64452
commit
a38c1ff4b3
10 files changed
+187
-57
No files matched your search
@@ -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]:
|
||||
|
||||
Reference in new issue
Block a user