Method
merge_extras
(e1: Dict[str, Any], e2: Dict[str, Any])
Source from the content-addressed store, hash-verified
| 248 | |
| 249 | @staticmethod |
| 250 | def merge_extras(e1: Dict[str, Any], e2: Dict[str, Any]) -> Dict[str, Any]: |
| 251 | def _concat(v1, v2): |
| 252 | if isinstance(v1, str): |
| 253 | v1 = [v1] |
| 254 | if isinstance(v2, str): |
| 255 | v2 = [v2] |
| 256 | v1.extend(v2) |
| 257 | return v1 |
| 258 | |
| 259 | if e1 is None: |
| 260 | return e2.copy() if e2 else None |
| 261 | if e2 is None: |
| 262 | return e1.copy() |
| 263 | e3 = e1.copy() |
| 264 | for name, val in e2.items(): |
| 265 | if name in e3: |
| 266 | e3[name] = _concat(e3[name], val) |
| 267 | else: |
| 268 | e3[name] = val |
| 269 | return e3 |
Tested by
no test coverage detected