Get value from nested dictionary using dot notation path
(obj, path)
| 43 | return {} |
| 44 | |
| 45 | def get_value_by_path(obj, path): |
| 46 | """Get value from nested dictionary using dot notation path""" |
| 47 | keys = path.split(".") |
| 48 | for key in keys: |
| 49 | if isinstance(obj, dict) and key in obj: |
| 50 | obj = obj[key] |
| 51 | else: |
| 52 | return "" |
| 53 | return str(obj) |
| 54 | |
| 55 | def replace_variables(text, variables): |
| 56 | """Replace variables in text with values from variables dictionary""" |