nwm_eval.utils.recursive_substitute#

nwm_eval.utils.recursive_substitute(obj, context)[source]#

Recursively substitute placeholders in nested structures.

Return type:

Any

Parameters:
  • obj – The object to perform substitution on, which can be a string, dictionary, list, or Pydantic BaseModel.

  • context – A dictionary containing the values to substitute into the string placeholders.

Returns:

The object with placeholders substituted according to the context. The structure of the object is preserved.