Harden formatter preset normalization
This commit is contained in:
@@ -77,7 +77,12 @@ def normalize_detail_level(value: str) -> str:
|
||||
return detail_policy.normalize_detail_level(value)
|
||||
|
||||
|
||||
def _choice_key(value: Any) -> str:
|
||||
return str(value or "").strip().lower().replace("-", "_").replace(" ", "_")
|
||||
|
||||
|
||||
def normalize_style_policy(value: str) -> str:
|
||||
value = _choice_key(value)
|
||||
return value if value in STYLE_POLICIES else "drop_style_tail"
|
||||
|
||||
|
||||
@@ -90,6 +95,7 @@ def caption_profile_choices() -> list[str]:
|
||||
|
||||
|
||||
def normalize_caption_profile(value: str) -> str:
|
||||
value = _choice_key(value)
|
||||
return value if value in CAPTION_PROFILES else CAPTION_PROFILE_DEFAULT
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user