- Split app.py into route blueprints (files, layers, images, polygon, mask, krita) - Create services layer (polygon_storage, comfyui, file_browser) - Extract config constants to config.py - Split templates into Jinja partials (base, components, modals) - Add browse dialog for visual file navigation - Add /api/browse endpoint for directory listing
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""Polygon storage service for in-memory polygon points."""
|
|
|
|
from typing import Any
|
|
|
|
|
|
class PolygonStorage:
|
|
"""In-memory storage for polygon points per ORA file."""
|
|
|
|
def __init__(self):
|
|
self._storage: dict[str, dict[str, Any]] = {}
|
|
|
|
def store(self, ora_path: str, points: list, color: str = '#FF0000', width: int = 2) -> None:
|
|
"""Store polygon data for an ORA file."""
|
|
self._storage[ora_path] = {
|
|
'points': points,
|
|
'color': color,
|
|
'width': width
|
|
}
|
|
|
|
def get(self, ora_path: str) -> dict[str, Any] | None:
|
|
"""Get polygon data for an ORA file."""
|
|
return self._storage.get(ora_path)
|
|
|
|
def clear(self, ora_path: str) -> bool:
|
|
"""Clear polygon data for an ORA file. Returns True if existed."""
|
|
if ora_path in self._storage:
|
|
del self._storage[ora_path]
|
|
return True
|
|
return False
|
|
|
|
def has_polygon(self, ora_path: str) -> bool:
|
|
"""Check if polygon exists for an ORA file."""
|
|
return ora_path in self._storage
|
|
|
|
|
|
polygon_storage = PolygonStorage()
|