Harden formatter preset normalization

This commit is contained in:
2026-06-27 14:07:38 +02:00
parent c34886b362
commit 0289a94153
3 changed files with 26 additions and 0 deletions
+9
View File
@@ -1,5 +1,7 @@
from __future__ import annotations
from typing import Any
DEFAULT_STYLE_PRESET = "flat_vector_pony"
DEFAULT_QUALITY_PRESET = "pony_high"
@@ -79,15 +81,22 @@ def sdxl_formatter_profile_choices() -> list[str]:
return list(SDXL_FORMATTER_PROFILES)
def _choice_key(value: Any) -> str:
return str(value or "").strip().lower().replace("-", "_").replace(" ", "_")
def normalize_style_preset(value: str) -> str:
value = _choice_key(value)
return value if value in SDXL_STYLE_PRESETS else DEFAULT_STYLE_PRESET
def normalize_quality_preset(value: str) -> str:
value = _choice_key(value)
return value if value in SDXL_QUALITY_PRESETS else DEFAULT_QUALITY_PRESET
def normalize_formatter_profile(value: str) -> str:
value = _choice_key(value)
return value if value in SDXL_FORMATTER_PROFILES else DEFAULT_FORMATTER_PROFILE