MCPcopy Create free account
hub / github.com/InternLM/InternBootcamp / _get_nested_value

Function _get_nested_value

internbootcamp/utils/data_postprocess.py:769–777  ·  view source on GitHub ↗

获取嵌套字段的值

(data: Dict[str, Any], path: str, default: Any = None)

Source from the content-addressed store, hash-verified

767 processor.add_transformer(extractor)
768 """
769 def _get_nested_value(data: Dict[str, Any], path: str, default: Any = None) -> Any:
770 """获取嵌套字段的值"""
771 value = data
772 for key in path.split('.'):
773 if isinstance(value, dict):
774 value = value.get(key, default)
775 else:
776 return default
777 return value
778
779 def _extract(data: Dict[str, Any]) -> Dict[str, Any]:
780 result = {}

Callers 2

_extractFunction · 0.85
_transformFunction · 0.85

Calls 2

splitMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected