metadata-writer: first skeleton
Tests / test_and_lint (push) Successful in 14s

This commit is contained in:
2026-10-04 07:54:33 +02:00
parent 6a12144e39
commit 1366e3b3e7
3 changed files with 59 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
import logging
from pathlib import Path
log = logging.getLogger(__name__)
# File extensions that should use XMP sidecars
SIDECAR_EXTENSIONS = {".dng", ".nef", ".cr2", ".cr3", ".arw", ".raf", ".orf", ".rw2"}
type Caption = str | None
type Keywords = list[str] | None
type Color = str | None
class MetadataWriter:
"""
Write metadata (captions and keywords) to image files.
For DNG files, creates/updates XMP sidecar files.
"""
def __init__(
self, force_sidecar: bool = False, append: bool = True, prefix: str = "photools"
):
self.force_sidecar = force_sidecar
self.append = append
self.prefix = prefix
def write_caption(self, path: Path, caption: Caption): ...
def write_keywords(self, path: Path, keywords: Keywords): ...
def write_color(self, path: Path, color: Color): ...
def write(
self,
path: Path,
caption: Caption = None,
keywords: Keywords = None,
color: Color = None,
):
if caption is not None:
self.write_caption(path, caption)
if keywords is not None:
self.write_keywords(path, keywords)
if color is not None:
self.write_color(path, color)