(data: Dict[str, Any])
| 828 | return value |
| 829 | |
| 830 | def _transform(data: Dict[str, Any]) -> Dict[str, Any]: |
| 831 | result = {} |
| 832 | for output_key, config in transform_dict.items(): |
| 833 | if callable(config): |
| 834 | # 自定义函数 |
| 835 | result[output_key] = config(data) |
| 836 | elif isinstance(config, tuple): |
| 837 | # (路径, 默认值) |
| 838 | path, default = config |
| 839 | result[output_key] = _get_nested_value(data, path, default) |
| 840 | elif isinstance(config, str): |
| 841 | # 字段路径 |
| 842 | result[output_key] = _get_nested_value(data, config) |
| 843 | else: |
| 844 | # 直接使用配置值 |
| 845 | result[output_key] = config |
| 846 | return result |
| 847 | |
| 848 | return _transform |
| 849 |
no test coverage detected