Coverage for fastblocks / adapters / icons / _base.py: 100%
22 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-02 20:00 -0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-02 20:00 -0800
1"""Base classes and protocols for icon adapters."""
3from contextlib import suppress
4from typing import Any, Protocol
5from uuid import UUID
7# Oneiric imports
8from oneiric.core.config import OneiricSettings
9from oneiric.core.resolution import Resolver
11# Oneiric resolver for dependency injection
12depends = Resolver()
15class IconsBaseSettings(OneiricSettings):
16 """Base settings for icon adapters using OneiricSettings."""
18 cdn_url: str | None = None
19 version: str = "latest"
20 default_prefix: str = ""
21 icon_mapping: dict[str, str] = {}
23 def __init__(self, **data: dict) -> None:
24 super().__init__(**data)
27class IconsProtocol(Protocol):
28 """Protocol for icon adapter implementations."""
30 def get_icon_class(self, icon_name: str) -> str: ...
31 def get_icon_tag(self, icon_name: str, **attributes: Any) -> str: ...
34class IconsBase:
35 """Base class for icon adapters using Oneiric patterns."""
37 # Oneiric-compatible metadata
38 MODULE_ID: UUID = UUID("01937d86-4f2a-7b3c-8d9e-f3b4d3c2b1a3") # Static UUID7
39 MODULE_STATUS = "stable"
41 def __init__(self) -> None:
42 """Initialize icon adapter."""
43 # Register with Oneiric resolver (fail gracefully if not supported)
44 with suppress(Exception):
45 depends.set(self)
47 def get_icon_class(self, icon_name: str) -> str:
48 """Get icon-specific class names."""
49 raise NotImplementedError()
51 def get_icon_tag(self, icon_name: str, **attributes: Any) -> str:
52 """Generate complete icon tags with attributes."""
53 raise NotImplementedError()
55 def get_stylesheet_links(self) -> list[str]:
56 """Get stylesheet link tags for the icon library."""
57 raise NotImplementedError()