summaryrefslogtreecommitdiff
path: root/lang/python/python-referencing
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2023-10-14 02:27:02 +0800
committerTianling Shen <cnsztl@gmail.com>2023-11-30 12:57:27 +0800
commit728aac31bb205bab208142d116b1c1d3e0f62a14 (patch)
tree38a70ecfb3b0d70525bf8e17e7252ed758dbb2ab /lang/python/python-referencing
parent06231ce8cbf82f39f93cc2fa216fc8aa3cd3271c (diff)
python-referencing: Add new package
From the README: An implementation-agnostic implementation of JSON reference resolution. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'lang/python/python-referencing')
-rw-r--r--lang/python/python-referencing/Makefile47
-rw-r--r--lang/python/python-referencing/test.sh35
2 files changed, 82 insertions, 0 deletions
diff --git a/lang/python/python-referencing/Makefile b/lang/python/python-referencing/Makefile
new file mode 100644
index 000000000..05f184a55
--- /dev/null
+++ b/lang/python/python-referencing/Makefile
@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2023 Jeffery To
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=python-referencing
+PKG_VERSION:=0.30.2
+PKG_RELEASE:=1
+
+PYPI_NAME:=referencing
+PKG_HASH:=794ad8003c65938edcdbc027f1933215e0d0ccc0291e3ce20a4d87432b59efc0
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYING
+PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
+
+PKG_BUILD_DEPENDS:=python-hatchling/host python-hatch-vcs/host
+
+include ../pypi.mk
+include $(INCLUDE_DIR)/package.mk
+include ../python3-package.mk
+
+define Package/python3-referencing
+ SECTION:=lang
+ CATEGORY:=Languages
+ SUBMENU:=Python
+ TITLE:=JSON Referencing + Python
+ URL:=https://github.com/python-jsonschema/referencing
+ DEPENDS:= \
+ +python3-light \
+ +python3-email \
+ +python3-urllib \
+ +python3-attrs \
+ +python3-rpds-py
+endef
+
+define Package/python3-referencing/description
+An implementation-agnostic implementation of JSON reference resolution.
+endef
+
+$(eval $(call Py3Package,python3-referencing))
+$(eval $(call BuildPackage,python3-referencing))
+$(eval $(call BuildPackage,python3-referencing-src))
diff --git a/lang/python/python-referencing/test.sh b/lang/python/python-referencing/test.sh
new file mode 100644
index 000000000..0517ba168
--- /dev/null
+++ b/lang/python/python-referencing/test.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+[ "$1" = python3-referencing ] || exit 0
+
+python3 - << 'EOF'
+
+from referencing import Registry, Resource
+import referencing.jsonschema
+
+schema = Resource.from_contents( # Parse some contents into a 2020-12 JSON Schema
+ {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "urn:example:a-202012-schema",
+ "$defs": {
+ "nonNegativeInteger": {
+ "$anchor": "nonNegativeInteger",
+ "type": "integer",
+ "minimum": 0,
+ },
+ },
+ }
+)
+registry = schema @ Registry() # Add the resource to a new registry
+
+# From here forward, this would usually be done within a library wrapping this one,
+# like a JSON Schema implementation
+resolver = registry.resolver()
+resolved = resolver.lookup("urn:example:a-202012-schema#nonNegativeInteger")
+assert resolved.contents == {
+ "$anchor": "nonNegativeInteger",
+ "type": "integer",
+ "minimum": 0,
+}
+
+EOF