36 lines
828 B
Python
36 lines
828 B
Python
"""Narration themes: the icon/word/color mapping for progress lines.
|
|
|
|
A theme is a narrate(msg) -> rich-markup-string function plus its name;
|
|
the CLI picks one with --theme (default 'default'). Drop a module in
|
|
evalharness/themes/ and it registers itself.
|
|
"""
|
|
from typing import Callable
|
|
|
|
from ..eval.registry import EvalRegistry
|
|
|
|
THEME_REGISTRY = EvalRegistry('narration theme')
|
|
|
|
|
|
def register_theme(name: str):
|
|
def decorator(fn: Callable[[str], str]):
|
|
THEME_REGISTRY.register(name, fn)
|
|
return fn
|
|
|
|
return decorator
|
|
|
|
|
|
def get_theme(name: str = 'default'):
|
|
return THEME_REGISTRY.get(name)
|
|
|
|
|
|
def _discover():
|
|
import importlib
|
|
import pkgutil
|
|
|
|
for m in pkgutil.iter_modules(__path__):
|
|
if m.name != '__init__':
|
|
importlib.import_module(f'{__name__}.{m.name}')
|
|
|
|
|
|
_discover()
|