Harden formatter preset normalization
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user