rdf4j-python 0.1.1a0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rdf4j_python/__init__.py +9 -4
- rdf4j_python/_client/_client.py +156 -5
- rdf4j_python/_driver/__init__.py +2 -0
- rdf4j_python/_driver/_async_named_graph.py +75 -0
- rdf4j_python/_driver/_async_rdf4j_db.py +55 -29
- rdf4j_python/_driver/_async_repository.py +289 -16
- rdf4j_python/exception/__init__.py +5 -0
- rdf4j_python/exception/repo_exception.py +26 -5
- rdf4j_python/model/__init__.py +7 -10
- rdf4j_python/model/_base_model.py +26 -4
- rdf4j_python/model/_dataset.py +38 -0
- rdf4j_python/model/_namespace.py +82 -4
- rdf4j_python/model/_repository_info.py +12 -1
- rdf4j_python/model/{_repository_config.py → repository_config.py} +565 -17
- rdf4j_python/model/term.py +14 -0
- rdf4j_python/model/vocabulary.py +6 -0
- rdf4j_python/utils/__init__.py +3 -0
- rdf4j_python/utils/const.py +4 -4
- rdf4j_python/utils/helpers.py +22 -0
- {rdf4j_python-0.1.1a0.dist-info → rdf4j_python-0.1.2.dist-info}/METADATA +12 -12
- rdf4j_python-0.1.2.dist-info/RECORD +25 -0
- {rdf4j_python-0.1.1a0.dist-info → rdf4j_python-0.1.2.dist-info}/WHEEL +1 -1
- rdf4j_python-0.1.1a0.dist-info/RECORD +0 -19
- {rdf4j_python-0.1.1a0.dist-info → rdf4j_python-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {rdf4j_python-0.1.1a0.dist-info → rdf4j_python-0.1.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from typing import Optional, Tuple, TypeAlias
|
|
2
|
+
|
|
3
|
+
from rdflib import URIRef as _URIRef
|
|
4
|
+
from rdflib.term import IdentifiedNode, Node
|
|
5
|
+
|
|
6
|
+
IRI: TypeAlias = _URIRef
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Subject: TypeAlias = Node
|
|
10
|
+
Predicate: TypeAlias = Node
|
|
11
|
+
Object: TypeAlias = Node
|
|
12
|
+
Context: TypeAlias = Optional[IdentifiedNode]
|
|
13
|
+
|
|
14
|
+
RDFStatement: TypeAlias = Tuple[Subject, Predicate, Object, Context]
|
rdf4j_python/utils/__init__.py
CHANGED
rdf4j_python/utils/const.py
CHANGED
|
@@ -12,11 +12,11 @@ class Rdf4jContentType(str, Enum):
|
|
|
12
12
|
RDF_XML = "application/rdf+xml"
|
|
13
13
|
RDF_JSON = "application/rdf+json"
|
|
14
14
|
LD_JSON = "application/ld+json"
|
|
15
|
-
NTRIPLES = "
|
|
15
|
+
NTRIPLES = "application/n-triples"
|
|
16
16
|
TURTLE = "text/turtle"
|
|
17
|
-
N3 = "text/
|
|
18
|
-
NQUADS = "
|
|
19
|
-
TRIG = "application/
|
|
17
|
+
N3 = "text/n3"
|
|
18
|
+
NQUADS = "application/n-quads"
|
|
19
|
+
TRIG = "application/trig"
|
|
20
20
|
TRIX = "application/trix"
|
|
21
21
|
BINARY_RDF = "application/x-binary-rdf"
|
|
22
22
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from typing import Iterable
|
|
2
|
+
|
|
3
|
+
from rdf4j_python.model.term import RDFStatement
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def serialize_statements(statements: Iterable[RDFStatement]) -> str:
|
|
7
|
+
"""Serializes statements to RDF data.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
statements (Iterable[RDFStatement]): RDF statements.
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
str: Serialized RDF data.
|
|
14
|
+
"""
|
|
15
|
+
lines = []
|
|
16
|
+
for subj, pred, obj, ctx in statements:
|
|
17
|
+
parts = [subj.n3(), pred.n3(), obj.n3()]
|
|
18
|
+
if ctx:
|
|
19
|
+
parts.append(ctx.n3())
|
|
20
|
+
parts.append(".")
|
|
21
|
+
lines.append(" ".join(parts))
|
|
22
|
+
return "\n".join(lines) + "\n"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rdf4j-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: The Python client for RDF4J
|
|
5
|
+
Author-email: Chengxu Bian <cbian564@gmail.com>
|
|
5
6
|
Requires-Python: >=3.10
|
|
6
7
|
Description-Content-Type: text/markdown
|
|
7
8
|
License-File: LICENSE
|
|
@@ -42,24 +43,23 @@ pip install rdf4j-python
|
|
|
42
43
|
Here's a basic example of how to use `rdf4j-python` to create an in-memory sail repository
|
|
43
44
|
|
|
44
45
|
```python
|
|
45
|
-
from rdf4j_python import AsyncRdf4j
|
|
46
|
-
from rdf4j_python.model import MemoryStoreConfig, RepositoryConfig
|
|
47
|
-
from rdf4j_python.utils.const import Rdf4jContentType
|
|
48
|
-
|
|
49
46
|
async with AsyncRdf4j("http://localhost:19780/rdf4j-server") as db:
|
|
50
47
|
repo_config = (
|
|
51
|
-
RepositoryConfig.
|
|
52
|
-
MemoryStoreConfig.Builder().persist(False).build(),
|
|
53
|
-
)
|
|
48
|
+
RepositoryConfig.Builder()
|
|
54
49
|
.repo_id("example-repo")
|
|
55
50
|
.title("Example Repository")
|
|
51
|
+
.sail_repository_impl(
|
|
52
|
+
MemoryStoreConfig.Builder().persist(False).build(),
|
|
53
|
+
)
|
|
56
54
|
.build()
|
|
57
55
|
)
|
|
58
|
-
await db.create_repository(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
repo = await db.create_repository(config=repo_config)
|
|
57
|
+
await repo.add_statement(
|
|
58
|
+
IRI("http://example.com/subject"),
|
|
59
|
+
IRI("http://example.com/predicate"),
|
|
60
|
+
Literal("test_object"),
|
|
62
61
|
)
|
|
62
|
+
await repo.get_statements(subject=IRI("http://example.com/subject"))
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
For more detailed examples, refer to the [examples](https://github.com/odysa/rdf4j-python/tree/main/examples) directory.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
rdf4j_python/__init__.py,sha256=E8gojaWuLHo2AfNn5HBc5cF7K8_dK2jOBcZaH_qoZs4,347
|
|
2
|
+
rdf4j_python/_client/__init__.py,sha256=L5q5RTHXCNyHp2WNP4xTemGXNntUW4RF_QJPoCWciUQ,98
|
|
3
|
+
rdf4j_python/_client/_client.py,sha256=JfHFudRDVkzmb_jWx1u2meqqFONImBQHuaoYkb4mWPc,7390
|
|
4
|
+
rdf4j_python/_driver/__init__.py,sha256=au0r15mQBVaJkqBknw9CoVswe7_rPPFs1wFWI_ttdy4,224
|
|
5
|
+
rdf4j_python/_driver/_async_named_graph.py,sha256=zpYr6x_9aI2wHH0Pj71LlCKkHFFanz7G77Tz5azXlg4,2642
|
|
6
|
+
rdf4j_python/_driver/_async_rdf4j_db.py,sha256=u6r4A4_CTp4JMEswl0I5rMjsuWnMkQV_TJrvF6u9R94,4403
|
|
7
|
+
rdf4j_python/_driver/_async_repository.py,sha256=NKM9IFLTNMepVCx_UeWc7h0BTxHMKfDnUcThz97pVCs,14075
|
|
8
|
+
rdf4j_python/exception/__init__.py,sha256=PFdUyIMsHIL5e2P2z33Qr2pwlUAJVI0G5T8114W4-1A,83
|
|
9
|
+
rdf4j_python/exception/repo_exception.py,sha256=WXlfIYzOYfNU8LpwtOct9fAZADR-P3cZx4jAX9v_HaA,704
|
|
10
|
+
rdf4j_python/model/__init__.py,sha256=eUvfFEPgDsbq37eIpd_dlvjpQPGuRwkKWNfqa0c2QwM,231
|
|
11
|
+
rdf4j_python/model/_base_model.py,sha256=PyhvLhaseKaFuRU70xord8EgIfO88-UVcllkuRobE14,1780
|
|
12
|
+
rdf4j_python/model/_dataset.py,sha256=-nYTm8Fz1CGsLL2ykmtGEJ9Jv4u8FC2Dgl_31LeoGhM,1065
|
|
13
|
+
rdf4j_python/model/_namespace.py,sha256=yaH-MjMFsUfCFadlo25MgHf9zaRbk-wkn_BgtmemVo4,3259
|
|
14
|
+
rdf4j_python/model/_repository_info.py,sha256=zSL3o_QWL06xYbnpFtXIg-PqFiRbwDFPb1aiy2JufYQ,1668
|
|
15
|
+
rdf4j_python/model/repository_config.py,sha256=WPXJAbZ2pM594Uh_r3zI6N1fqObSsk74ArVZTTdqPks,55012
|
|
16
|
+
rdf4j_python/model/term.py,sha256=FkK8-HG6h79dAYO_qiTYTxvu8t-d5zVY5FtgJrW997o,352
|
|
17
|
+
rdf4j_python/model/vocabulary.py,sha256=R9k9dzDPwRBEgwjIF6sNZh3hL41R7GZ1eSJKb8w7IaY,247
|
|
18
|
+
rdf4j_python/utils/__init__.py,sha256=LAyzkmO5QOIjJogQE1m4Eszwb2cCU8ytKRfhjAGoraw,34
|
|
19
|
+
rdf4j_python/utils/const.py,sha256=HKH9ZGe7m_dvMx1RwT6zhu2HUkvwOX2Y4e8vQFs3uE8,849
|
|
20
|
+
rdf4j_python/utils/helpers.py,sha256=xnMB_imsybGQ2GiHvXK4wEpcs4ADiqZ4ez0yop_ko8E,577
|
|
21
|
+
rdf4j_python-0.1.2.dist-info/licenses/LICENSE,sha256=sGjA7CzoCG1LVlkh0ZB76ZdgWHVpUFegLU41YYDkGIA,1499
|
|
22
|
+
rdf4j_python-0.1.2.dist-info/METADATA,sha256=7V13OG7A4fxFPLcwbIUjsqUCVDwC1dlqXE5YSHw7PbU,2852
|
|
23
|
+
rdf4j_python-0.1.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
24
|
+
rdf4j_python-0.1.2.dist-info/top_level.txt,sha256=Lf2K8d8WcEkmvo5giLGuZ3gl20rNEwMssyAFBeVzbCs,13
|
|
25
|
+
rdf4j_python-0.1.2.dist-info/RECORD,,
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
rdf4j_python/__init__.py,sha256=Ltuo15XbZKeKwBTbl2q03OYDZvmYshsMbxxlRtpgJiE,209
|
|
2
|
-
rdf4j_python/_client/__init__.py,sha256=L5q5RTHXCNyHp2WNP4xTemGXNntUW4RF_QJPoCWciUQ,98
|
|
3
|
-
rdf4j_python/_client/_client.py,sha256=gBuw0tfV18SXUmoh4JgJcaa-RwxkGejm2LnQwYlbmIo,3105
|
|
4
|
-
rdf4j_python/_driver/__init__.py,sha256=p4UG1SImBOJHRQFqfYczTv3WnLoy2Me-bpcAYC1nK9E,153
|
|
5
|
-
rdf4j_python/_driver/_async_rdf4j_db.py,sha256=FG0ziBVBmjKQat2voalgvY944hPVyIVXAavIXgNmH5c,3493
|
|
6
|
-
rdf4j_python/_driver/_async_repository.py,sha256=X_IeQaRcLmFlCNTkTH5hTqhPQlzE69PbOac1NuvI7K4,4700
|
|
7
|
-
rdf4j_python/exception/repo_exception.py,sha256=29lQ_1_Ir4GIoCbbOCMCCy0a_YxhMfsjxYTwUNNpRjQ,249
|
|
8
|
-
rdf4j_python/model/__init__.py,sha256=qBJeBaIS_eTBbvxn8IrEbEAbZawRs2-cIG4SQOd3kZE,335
|
|
9
|
-
rdf4j_python/model/_base_model.py,sha256=YOcgb83NfObDlrj7-d8f3yg1ZJGzkKs4blI7wOYb4LA,812
|
|
10
|
-
rdf4j_python/model/_namespace.py,sha256=9ic_Nh1pKWNn4g2qTgAtlKiSr1DzzY8qWAPvqgjWuIw,1483
|
|
11
|
-
rdf4j_python/model/_repository_config.py,sha256=iWfC-81d-blzqPQ6CiQEvZViOQQMGFz6LMYR9AnSLxg,34451
|
|
12
|
-
rdf4j_python/model/_repository_info.py,sha256=ZFwIjL_ZzdF_PZPOQRgxF8iMBM1MI261ZVxK3o1FLJU,1373
|
|
13
|
-
rdf4j_python/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
rdf4j_python/utils/const.py,sha256=awf0oGwDs54K02v2GPl2vTgUvrjG0YbX6cAUfXFMsug,838
|
|
15
|
-
rdf4j_python-0.1.1a0.dist-info/licenses/LICENSE,sha256=sGjA7CzoCG1LVlkh0ZB76ZdgWHVpUFegLU41YYDkGIA,1499
|
|
16
|
-
rdf4j_python-0.1.1a0.dist-info/METADATA,sha256=17yBFlB7wTbduJapzrQWc_ZgRCRMEpSK8v7IFyrtq2w,2842
|
|
17
|
-
rdf4j_python-0.1.1a0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
18
|
-
rdf4j_python-0.1.1a0.dist-info/top_level.txt,sha256=Lf2K8d8WcEkmvo5giLGuZ3gl20rNEwMssyAFBeVzbCs,13
|
|
19
|
-
rdf4j_python-0.1.1a0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|