rdf4j-python 0.1.0__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.
@@ -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]
@@ -0,0 +1,6 @@
1
+ from rdf4j_python.model import Namespace
2
+
3
+ # Common namespaces
4
+ RDF = Namespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
5
+ RDFS = Namespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
6
+ EXAMPLE = Namespace("ex", "http://example.org/")
@@ -0,0 +1,3 @@
1
+ """
2
+ RDF4J Python Utils Module
3
+ """
@@ -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 = "text/plain"
15
+ NTRIPLES = "application/n-triples"
16
16
  TURTLE = "text/turtle"
17
- N3 = "text/rdf+n3"
18
- NQUADS = "text/x-nquads"
19
- TRIG = "application/x-trig"
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"
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: rdf4j-python
3
+ Version: 0.1.2
4
+ Summary: The Python client for RDF4J
5
+ Author-email: Chengxu Bian <cbian564@gmail.com>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: httpx>=0.28.1
10
+ Requires-Dist: rdflib>=7.1.4
11
+ Dynamic: license-file
12
+
13
+ # 🐍 rdf4j-python
14
+
15
+ **A Pythonic interface to the powerful Java-based [Eclipse RDF4J](https://rdf4j.org/) framework.**
16
+
17
+ > ⚠️ **Note:** This project is currently under active development and considered **experimental**. Interfaces may change. Use with caution in production environments—and feel free to help shape its future!
18
+
19
+ ✅ **Supports both asynchronous (`async/await`) and synchronous programming styles.**
20
+
21
+ ## 🌐 Overview
22
+
23
+ `rdf4j-python` bridges the gap between Python applications and the [Eclipse RDF4J](https://rdf4j.org/) framework, enabling seamless interaction with RDF4J repositories directly from Python. This integration allows developers to leverage RDF4J's robust capabilities for managing RDF data and executing SPARQL queries without leaving the Python ecosystem.
24
+
25
+ ## 🚀 Features
26
+
27
+ - **Seamless Integration**: Interact with RDF4J repositories using Pythonic constructs.
28
+ - **SPARQL Support**: Execute SPARQL queries and updates effortlessly.
29
+ - **Repository Management**: Create, access, and manage RDF4J repositories programmatically.
30
+ - **Data Handling**: Add and retrieve RDF triples with ease.
31
+ - **Format Flexibility**: Support for various RDF serialization formats.
32
+
33
+ ## 📦 Installation
34
+
35
+ Install via pip:
36
+
37
+ ```bash
38
+ pip install rdf4j-python
39
+ ```
40
+
41
+ ## 🧪 Usage (Async)
42
+
43
+ Here's a basic example of how to use `rdf4j-python` to create an in-memory sail repository
44
+
45
+ ```python
46
+ async with AsyncRdf4j("http://localhost:19780/rdf4j-server") as db:
47
+ repo_config = (
48
+ RepositoryConfig.Builder()
49
+ .repo_id("example-repo")
50
+ .title("Example Repository")
51
+ .sail_repository_impl(
52
+ MemoryStoreConfig.Builder().persist(False).build(),
53
+ )
54
+ .build()
55
+ )
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"),
61
+ )
62
+ await repo.get_statements(subject=IRI("http://example.com/subject"))
63
+ ```
64
+
65
+ For more detailed examples, refer to the [examples](https://github.com/odysa/rdf4j-python/tree/main/examples) directory.
66
+
67
+ ## 🤝 Contributing
68
+
69
+ We welcome contributions and feedback! If you'd like to help improve this project:
70
+
71
+ - Fork the repo and submit a pull request
72
+ - Open an issue for bugs, feature ideas, or discussions
73
+ - ⭐ Star the repo if you find it useful!
74
+
75
+ ## 📄 License
76
+
77
+ This project is licensed under the MIT License. See the [LICENSE](https://github.com/odysa/rdf4j-python/blob/main/LICENSE) file for details.
@@ -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,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Chengxu Bian
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,8 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: rdf4j-python
3
- Version: 0.1.0
4
- Summary: The Python client for RDF4J
5
- Requires-Python: >=3.10
6
- Description-Content-Type: text/markdown
7
- Requires-Dist: httpx>=0.28.1
8
- Requires-Dist: rdflib>=7.1.4
@@ -1,15 +0,0 @@
1
- rdf4j_python/__init__.py,sha256=-Ux0t15UPMS7zpvvedvR2xs8wtY5k_TiY74YdExI2PY,203
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=ryxQ9zig30THoIFcFvSYouof7OEvoeaven15gzQqUZY,147
5
- rdf4j_python/_driver/_async_rdf4j_db.py,sha256=nUYXhZ2ku8ibRfPjveEv246P86-eXYiRS_u2-uRP-0U,3361
6
- rdf4j_python/_driver/_async_repository.py,sha256=xTaR8RJdnQFZ4s43KXRm7rr9YNQO8_Me2S6CGjSRYIk,2132
7
- rdf4j_python/exception/repo_exception.py,sha256=-PMWkw1ieOeSCHt1jHwIFHQsrXJn3KGsBWIn58-833w,102
8
- rdf4j_python/model/_base_model.py,sha256=YOcgb83NfObDlrj7-d8f3yg1ZJGzkKs4blI7wOYb4LA,812
9
- rdf4j_python/model/repository.py,sha256=LLKJnCer9dRDs-aS_Fyn3vKfmmRbmWguLuJlxvCWTro,1368
10
- rdf4j_python/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- rdf4j_python/utils/const.py,sha256=awf0oGwDs54K02v2GPl2vTgUvrjG0YbX6cAUfXFMsug,838
12
- rdf4j_python-0.1.0.dist-info/METADATA,sha256=HNAT_i0qrKvFotzwclMSoIA8R7Ct9MHEB1DF7fAco-Y,215
13
- rdf4j_python-0.1.0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
14
- rdf4j_python-0.1.0.dist-info/top_level.txt,sha256=Lf2K8d8WcEkmvo5giLGuZ3gl20rNEwMssyAFBeVzbCs,13
15
- rdf4j_python-0.1.0.dist-info/RECORD,,