File: jfollow.py

package info (click to toggle)
blebox-uniapi 2.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 520 kB
  • sloc: python: 4,994; makefile: 85; sh: 5
file content (11 lines) | stat: -rw-r--r-- 278 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
from typing import Any, Union

import jmespath


def follow(data: Union[dict, list], path: str) -> Any:
    if data is None:
        raise RuntimeError(f"bad argument: data {data}")  # pragma: no cover

    expression = jmespath.compile(path)
    return expression.search(data)