PKG_NAME:=python-jsonpath-ng
PKG_VERSION:=1.8.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_MAINTAINER:=Josef Schlehofer <pepe.schlehofer@gmail.com>
PYPI_NAME:=jsonpath-ng
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE
+PKG_BUILD_DEPENDS:=python-setuptools/host
+
include ../pypi.mk
include $(INCLUDE_DIR)/package.mk
include ../python3-package.mk
TITLE:=Standard compliant implementation of JSONPath
DEPENDS:= \
+python3-light \
- +python3-logging \
- +python3-ply \
- +python3-six \
- +python3-decorator
+ +python3-logging
endef
define Package/python3-jsonpath-ng/description
--- /dev/null
+#!/bin/sh
+
+# shellcheck shell=busybox
+
+# The jsonpath_ng command-line tool takes a required expression argument and
+# has no version flag, so the generic version check cannot detect the version
+# from it. The version is covered by the import check in test.sh instead.
+case "$PKG_NAME" in
+python3-jsonpath-ng | python3-jsonpath-ng-src)
+ exit 0
+ ;;
+*)
+ echo "Untested package: $PKG_NAME" >&2
+ exit 1
+ ;;
+esac
[ "$1" = python3-jsonpath-ng ] || exit 0
-python3 - << 'EOF'
+python3 - "$2" << 'EOF'
+import sys
+import jsonpath_ng
from jsonpath_ng import parse
from jsonpath_ng.ext import parse as ext_parse
+# The jsonpath_ng CLI has no version flag, so the generic version check is
+# overridden (test-version.sh); confirm the package version here instead.
+if jsonpath_ng.__version__ != sys.argv[1]:
+ print("Wrong version: " + jsonpath_ng.__version__)
+ sys.exit(1)
+
data = {
"store": {
"books": [
expr2 = parse("store.books[1].price")
assert expr2.find(data)[0].value == 20
-# Filter expression (ext parser)
+# Filter expression (ext parser, exercises the vendored ply lexer/parser)
expr3 = ext_parse("store.books[?price > 12].title")
titles = [m.value for m in expr3.find(data)]
assert set(titles) == {"B", "C"}, f"Unexpected: {titles}"
EOF
+[ $? -eq 0 ] || exit 1
+
+# Verify the jsonpath_ng command-line tool (reads JSON from stdin)
+result=$(echo '{"a": {"b": 42}}' | jsonpath_ng 'a.b')
+[ "$result" = "42" ] || {
+ echo "jsonpath_ng returned '$result', expected 42"
+ exit 1
+}