Skip to content

Commit 26751fc

Browse files
Panaetiusmr-c
authored andcommitted
Attempt to add rdflib 5.0.0
1 parent 48df828 commit 26751fc

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ruamel.yaml>=0.12.4, <= 0.16.5
2-
rdflib==4.2.2
3-
rdflib-jsonld==0.4.0
2+
rdflib>=4.2.2, <= 5.0.0
3+
rdflib-jsonld>=0.4.0, <0.6.0
44
mistune>=0.8.1,<0.9
55
CacheControl==0.11.7
66
lockfile==0.12.2

schema_salad/jsonld_context.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,30 @@ def process_type(
148148
v = v["_@id"] if v.get("_@id", "@")[0] != "@" else None
149149

150150
if bool(v):
151-
(ns, ln) = rdflib.namespace.split_uri(str(v))
151+
try:
152+
(ns, ln) = rdflib.namespace.split_uri(str(v))
153+
except ValueError:
154+
# rdflib 5.0.0 compatibility
155+
uri = str(v)
156+
colon_index = str(v).rfind(":")
157+
158+
if colon_index < 0:
159+
raise
160+
split_start = rdflib.namespace.SPLIT_START_CATEGORIES
161+
for j in range(-1 - colon_index, len(uri)):
162+
if (
163+
rdflib.namespace.category(uri[j]) in split_start
164+
or uri[j] == "_"
165+
):
166+
# _ prevents early split, roundtrip not generate
167+
ns = uri[:j]
168+
if not ns:
169+
break
170+
ln = uri[j:]
171+
break
172+
if not ns or not ln:
173+
raise
174+
152175
if ns[0:-1] in namespaces:
153176
propnode = namespaces[ns[0:-1]][ln]
154177
else:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"ruamel.yaml >= 0.12.4, <= 0.16.5",
8585
# once the minimum version for ruamel.yaml >= 0.15.99
8686
# then please update the mypy targets in the Makefile
87-
"rdflib >= 4.2.2, < 4.3.0",
87+
"rdflib >= 4.2.2, <= 5.0.0",
8888
"rdflib-jsonld >= 0.3.0, < 0.6.0",
8989
"mistune >= 0.8.1, < 0.9",
9090
"CacheControl >= 0.11.7, < 0.12",

0 commit comments

Comments
 (0)