MCPcopy
hub / github.com/pingcap/docs-cn / get_value_by_path

Function get_value_by_path

scripts/merge_by_toc.py:45–53  ·  view source on GitHub ↗

Get value from nested dictionary using dot notation path

(obj, path)

Source from the content-addressed store, hash-verified

43 return {}
44
45def 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
55def replace_variables(text, variables):
56 """Replace variables in text with values from variables dictionary"""

Callers 1

replacerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected