Skip to content

Commit

Permalink
feat(template.mustache): normalize strings by removing _ and -
Browse files Browse the repository at this point in the history
  • Loading branch information
loqusion committed May 3, 2024
1 parent 842ffda commit febae39
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/hyprshade/template/mustache.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ def render(


def normalize_data(data: dict[str, Any]) -> dict[str, Any]:
return {x: (y.upper() if isinstance(y, str) else y) for x, y in data.items()}
return {
x: (normalize_string(y) if isinstance(y, str) else y) for x, y in data.items()
}


NORMALIZE_STRING_REPLACEMENT_PATTERN: Final = re.compile(r"[_-]")


def normalize_string(data: str) -> str:
return NORMALIZE_STRING_REPLACEMENT_PATTERN.sub("", data.upper())


NULLISH_COALESCE_OPERATOR_PATTERN: Final = re.compile(r"\s*\?\s*")
Expand Down

0 comments on commit febae39

Please sign in to comment.