| 1 |
from typing import Any, Union |
| 2 |
|
| 3 |
import jmespath |
| 4 |
|
| 5 |
|
| 6 |
def follow(data: Union[dict, list], path: str) -> Any: |
| 7 |
if data is None: |
| 8 |
raise RuntimeError(f"bad argument: data {data}") |
| 9 |
|
| 10 |
expression = jmespath.compile(path) |
| 11 |
return expression.search(data) |