nicetoolbox.configs.placeholders.resolve_placeholders_str¶
- nicetoolbox.configs.placeholders.resolve_placeholders_str(input: str, placeholders: dict[str, Union[str, int, float, bool]], unresolved: set[str] | None = None, unreachable: set[str] | None = None) str[source]¶
Find and resolve placeholders in a string with corresponding values from dictionary. Placeholders should be formatted as <var> strings. If placeholders key isn’t inside dict, it will be ignored and added to optional unresolved placeholders set.
- Parameters:
input (str) – The string containing placeholders to be replaced.
placeholders (dict[str, PLACEHOLDERS_TYPE]) – A dictionary containing the placeholder values.
unresolved (set, optional) – A set to collect unresolved placeholder keys. Placeholder is unresolved if it’s not present in dict or its value contains unresolved placeholders (including unreachable placeholders).
unreachable (set, optional) – Set of placeholder names that are allowed to remain unresolved (e.g., runtime placeholders resolved later).
- Returns:
The string with placeholders replaced.
- Return type:
str