- Separate CaptureEngine into stateless factory + stateful CaptureStream session - Add LiveStream/LiveStreamManager for shared capture with reference counting - Rename PictureStream to PictureSource across storage, API, and UI - Remove legacy migration logic and unused compatibility code - Split monolithic routes.py (1935 lines) into 5 focused route modules - Split schemas.py (480 lines) into 7 schema modules with re-exports - Extract dependency injection into dedicated dependencies.py Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
"""Postprocessing template data model."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from wled_controller.core.filters.filter_instance import FilterInstance
|
|
|
|
|
|
@dataclass
|
|
class PostprocessingTemplate:
|
|
"""Postprocessing settings template containing an ordered list of filters."""
|
|
|
|
id: str
|
|
name: str
|
|
filters: List[FilterInstance]
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
description: Optional[str] = None
|
|
|
|
def to_dict(self) -> dict:
|
|
"""Convert template to dictionary."""
|
|
return {
|
|
"id": self.id,
|
|
"name": self.name,
|
|
"filters": [f.to_dict() for f in self.filters],
|
|
"created_at": self.created_at.isoformat(),
|
|
"updated_at": self.updated_at.isoformat(),
|
|
"description": self.description,
|
|
}
|
|
|
|
@classmethod
|
|
def from_dict(cls, data: dict) -> "PostprocessingTemplate":
|
|
"""Create template from dictionary."""
|
|
filters = [FilterInstance.from_dict(f) for f in data.get("filters", [])]
|
|
|
|
return cls(
|
|
id=data["id"],
|
|
name=data["name"],
|
|
filters=filters,
|
|
created_at=datetime.fromisoformat(data["created_at"])
|
|
if isinstance(data.get("created_at"), str)
|
|
else data.get("created_at", datetime.utcnow()),
|
|
updated_at=datetime.fromisoformat(data["updated_at"])
|
|
if isinstance(data.get("updated_at"), str)
|
|
else data.get("updated_at", datetime.utcnow()),
|
|
description=data.get("description"),
|
|
)
|