Skip to content

Commit 561d5e1

Browse files
authored
Merge branch 'main' into sparql-connector-default-graph
2 parents dfa071c + 14d1006 commit 561d5e1

File tree

77 files changed

+3144
-734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3144
-734
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ unsure about them, submit your PR as is and ask for help.
5858
- [ ] Created an issue to discuss the change and get in-principle agreement.
5959
- [ ] Considered adding an example in `./examples`.
6060
- If the change has a potential impact on users of this project:
61-
<!-- This can be removed if the changed does affect users of this project. -->
61+
<!-- This can be removed if the change does not affect users of this project. -->
6262
- [ ] Added or updated tests that fail without the change.
6363
- [ ] Updated relevant documentation to avoid inaccuracies.
6464
- [ ] Considered adding additional documentation.

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ updates:
1313
versions:
1414
- 3.4.3
1515
- 3.5.2
16+
# We only use setuptools for a couple of things in the test suite
17+
# There is no need to keep it bleeding-edge. There are too frequent
18+
# updates to setuptools, requires too much maintenance to keep it up to date.
19+
- dependency-name: setuptools
20+
versions:
21+
- ">=72.0"
22+
- dependency-name: types-setuptools
23+
versions:
24+
- ">=72.0"
1625
# Ignore all black updates, because we use a pinned version we don't want to change
1726
- dependency-name: black
1827
# Ignore types-setuptools patch-level updates, because they issue too many!

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The stable release of RDFLib may be installed with Python's package management t
6262

6363
Some features of RDFLib require optional dependencies which may be installed using *pip* extras:
6464

65-
$ pip install rdflib[berkeleydb,networkx,html,lxml]
65+
$ pip install rdflib[berkeleydb,networkx,html,lxml,orjson]
6666

6767
Alternatively manually download the package from the Python Package
6868
Index (PyPI) at https://pypi.python.org/pypi/rdflib

devtools/constraints.min

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ berkeleydb==18.1.2
88
networkx==2.0
99
html5lib==1.0.1
1010
lxml==4.3.0
11+
orjson==3.9.14

docker/latest/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/library/python:3.12.4-slim@sha256:52f92c54e879539342692d20a4bea99516d4a2eb3cd16dfbb4e4b964aa8becaa
1+
FROM docker.io/library/python:3.12.6-slim@sha256:15bad989b293be1dd5eb26a87ecacadaee1559f98e29f02bf6d00c8d86129f39
22

33
COPY docker/latest/requirements.txt /var/tmp/build/
44

docker/unstable/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/library/python:3.12.4-slim@sha256:52f92c54e879539342692d20a4bea99516d4a2eb3cd16dfbb4e4b964aa8becaa
1+
FROM docker.io/library/python:3.12.6-slim@sha256:15bad989b293be1dd5eb26a87ecacadaee1559f98e29f02bf6d00c8d86129f39
22

33
# This file is generated from docker:unstable in Taskfile.yml
44
COPY var/requirements.txt /var/tmp/build/

docs/plugin_parsers.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ json-ld :class:`~rdflib.plugins.parsers.jsonld.JsonLDParser`
2424
hext :class:`~rdflib.plugins.parsers.hext.HextuplesParser`
2525
n3 :class:`~rdflib.plugins.parsers.notation3.N3Parser`
2626
nquads :class:`~rdflib.plugins.parsers.nquads.NQuadsParser`
27+
patch :class:`~rdflib.plugins.parsers.patch.RDFPatchParser`
2728
nt :class:`~rdflib.plugins.parsers.ntriples.NTParser`
2829
trix :class:`~rdflib.plugins.parsers.trix.TriXParser`
2930
turtle :class:`~rdflib.plugins.parsers.notation3.TurtleParser`

docs/plugin_serializers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ n3 :class:`~rdflib.plugins.serializers.n3.N3Serializer`
2121
nquads :class:`~rdflib.plugins.serializers.nquads.NQuadsSerializer`
2222
nt :class:`~rdflib.plugins.serializers.nt.NTSerializer`
2323
hext :class:`~rdflib.plugins.serializers.hext.HextuplesSerializer`
24+
patch :class:`~rdflib.plugins.serializers.patch.PatchSerializer`
2425
pretty-xml :class:`~rdflib.plugins.serializers.rdfxml.PrettyXMLSerializer`
2526
trig :class:`~rdflib.plugins.serializers.trig.TrigSerializer`
2627
trix :class:`~rdflib.plugins.serializers.trix.TriXSerializer`
@@ -34,6 +35,11 @@ JSON-LD
3435
-------
3536
JSON-LD - 'json-ld' - has been incorporated into RDFLib since v6.0.0.
3637

38+
RDF Patch
39+
---------
40+
41+
The RDF Patch Serializer - 'patch' - uses the RDF Patch format defined at https://afs.github.io/rdf-patch/. It supports serializing context aware stores as either addition or deletion patches; and also supports serializing the difference between two context aware stores as a Patch of additions and deletions.
42+
3743
HexTuples
3844
---------
3945
The HexTuples Serializer - 'hext' - uses the HexTuples format defined at https://github.com/ontola/hextuples.

examples/parse_patch.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from rdflib import Dataset
2+
3+
4+
def main():
5+
# RDF patch data
6+
add_patch = """
7+
TX .
8+
A _:bn1 <http://example.org/predicate1> "object1" .
9+
A _:bn1 <http://example.org/predicate2> "object2" .
10+
TC .
11+
"""
12+
13+
delete_patch = """
14+
TX .
15+
D _:bn1 <http://example.org/predicate1> "object1" .
16+
TC .
17+
"""
18+
19+
ds = Dataset()
20+
21+
# Apply add patch
22+
ds.parse(data=add_patch, format="patch")
23+
print("After add patch:")
24+
for triple in ds:
25+
print(triple)
26+
27+
# Apply delete patch
28+
ds.parse(data=delete_patch, format="patch")
29+
print("After delete patch:")
30+
for triple in ds:
31+
print(triple)
32+
33+
34+
if __name__ == "__main__":
35+
main()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from rdflib import Dataset, Graph, Literal, URIRef
2+
3+
4+
def main():
5+
# example for adding a quad
6+
ds = Dataset()
7+
g = Graph(identifier=URIRef("http://graph-a"))
8+
ds.add_graph(g)
9+
triple = (URIRef("http://subj-a"), URIRef("http://pred-a"), Literal("obj-a"))
10+
ds.get_context(g.identifier).add(triple)
11+
result = ds.serialize(format="patch", operation="add")
12+
print("Add Quad Patch:")
13+
print(result)
14+
15+
# alternate example for adding a quad
16+
ds = Dataset()
17+
quad = (
18+
URIRef("http://subj-a"),
19+
URIRef("http://pred-a"),
20+
Literal("obj-a"),
21+
Graph(identifier=URIRef("http://graph-a")),
22+
)
23+
ds.add(quad)
24+
result = ds.serialize(format="patch", operation="add")
25+
print("Add Quad Patch:")
26+
print(result)
27+
28+
# example for adding a triple
29+
ds = Dataset()
30+
ds.add(triple)
31+
result = ds.serialize(format="patch", operation="add")
32+
print("\nAdd Triple Patch:")
33+
print(result)
34+
35+
# Example for diff quads
36+
quad_1 = (
37+
URIRef("http://subj-a"),
38+
URIRef("http://pred-a"),
39+
Literal("obj-a"),
40+
Graph(identifier=URIRef("http://graph-a")),
41+
)
42+
quad_2 = (
43+
URIRef("http://subj-b"),
44+
URIRef("http://pred-b"),
45+
Literal("obj-b"),
46+
Graph(identifier=URIRef("http://graph-b")),
47+
)
48+
quad_3 = (
49+
URIRef("http://subj-c"),
50+
URIRef("http://pred-c"),
51+
Literal("obj-c"),
52+
Graph(identifier=URIRef("http://graph-c")),
53+
)
54+
ds1 = Dataset()
55+
ds2 = Dataset()
56+
ds1.addN([quad_1, quad_2])
57+
ds2.addN([quad_2, quad_3])
58+
result = ds1.serialize(format="patch", target=ds2)
59+
print("Diff Quad Patch:")
60+
print(result)
61+
62+
63+
if __name__ == "__main__":
64+
main()

0 commit comments

Comments
 (0)