| 39 | |
| 40 | |
| 41 | def find_replace_str(value, replace_dict): |
| 42 | if not isinstance(value, str): |
| 43 | return str(value) |
| 44 | |
| 45 | matches = re.findall(r"\$[A-Za-z0-9_]+", value) |
| 46 | for var in matches: |
| 47 | var_key = var.replace("$", "").lower() |
| 48 | if var_key == "nvme_path": |
| 49 | continue |
| 50 | assert var_key in replace_dict, f"unknown var key: {var_key}, in {replace_dict}" |
| 51 | if isinstance(replace_dict[var_key], str): |
| 52 | value = value.replace(var, replace_dict[var_key]) |
| 53 | else: |
| 54 | assert len(matches) == 1, "unable to replace multiple non-string matches" |
| 55 | value = replace_dict[var_key] |
| 56 | return value |
| 57 | |
| 58 | |
| 59 | def find_replace(target, replace_dict): |