23 lines
632 B
Python
23 lines
632 B
Python
from styles.blink import BlinkStyle
|
|||
|
|
from styles.simple import SimpleStyle
|
||
|
|
|
||
|
|
# Registry of available alarm styles. Add a line here when you add a style.
|
||
|
|
STYLES = {
|
||
|
|
"blink": BlinkStyle,
|
||
|
|
"simple": SimpleStyle,
|
||
|
|
}
|
||
|
|
|
||
|
|
# Fallback style for legacy cron entries that predate --style, so an upgrade
|
||
|
|
# never silently changes an existing alarm's behaviour.
|
||
|
|
LEGACY_STYLE = "blink"
|
||
|
|
|
||
|
|
|
||
|
|
def get_style(name: str):
|
||
|
|
"""Return the style class for ``name`` or raise ValueError."""
|
||
|
|
try:
|
||
|
|
return STYLES[name]
|
||
|
|
except KeyError:
|
||
|
|
raise ValueError(
|
||
|
|
f"Unknown alarm style: {name!r}. Known: {sorted(STYLES)}"
|
||
|
|
)
|