rdf4j-python 0.1.5__tar.gz → 0.1.6__tar.gz

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.
Files changed (33) hide show
  1. {rdf4j_python-0.1.5/rdf4j_python.egg-info → rdf4j_python-0.1.6}/PKG-INFO +1 -1
  2. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/pyproject.toml +1 -1
  3. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/_client/_client.py +6 -0
  4. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/_driver/_async_rdf4j_db.py +7 -2
  5. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6/rdf4j_python.egg-info}/PKG-INFO +1 -1
  6. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/tests/test_client.py +22 -0
  7. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/LICENSE +0 -0
  8. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/README.md +0 -0
  9. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/__init__.py +0 -0
  10. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/_client/__init__.py +0 -0
  11. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/_driver/__init__.py +0 -0
  12. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/_driver/_async_named_graph.py +0 -0
  13. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/_driver/_async_repository.py +0 -0
  14. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/exception/__init__.py +0 -0
  15. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/exception/repo_exception.py +0 -0
  16. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/model/__init__.py +0 -0
  17. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/model/_namespace.py +0 -0
  18. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/model/_repository_info.py +0 -0
  19. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/model/repository_config.py +0 -0
  20. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/model/term.py +0 -0
  21. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/model/vocabulary.py +0 -0
  22. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/utils/__init__.py +0 -0
  23. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/utils/const.py +0 -0
  24. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python/utils/helpers.py +0 -0
  25. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python.egg-info/SOURCES.txt +0 -0
  26. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python.egg-info/dependency_links.txt +0 -0
  27. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python.egg-info/requires.txt +0 -0
  28. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/rdf4j_python.egg-info/top_level.txt +0 -0
  29. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/setup.cfg +0 -0
  30. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/tests/test_async_named_graph.py +0 -0
  31. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/tests/test_client_initialization.py +0 -0
  32. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/tests/test_helpers.py +0 -0
  33. {rdf4j_python-0.1.5 → rdf4j_python-0.1.6}/tests/test_rdf4j_repository.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdf4j-python
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: The Python client for RDF4J
5
5
  Author-email: Chengxu Bian <cbian564@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "rdf4j-python"
3
3
  authors = [{ name = "Chengxu Bian", email = "cbian564@gmail.com" }]
4
- version = "0.1.5"
4
+ version = "0.1.6"
5
5
  description = "The Python client for RDF4J"
6
6
  readme = "README.md"
7
7
  requires-python = ">=3.10"
@@ -273,3 +273,9 @@ class AsyncApiClient(BaseClient):
273
273
  return await self.client.delete(
274
274
  self._build_url(path), params=params, headers=headers
275
275
  )
276
+
277
+ async def aclose(self):
278
+ """
279
+ Asynchronously closes the client connection.
280
+ """
281
+ await self.client.aclose()
@@ -26,6 +26,7 @@ class AsyncRdf4j:
26
26
  base_url (str): Base URL of the RDF4J server.
27
27
  """
28
28
  self._base_url = base_url.rstrip("/")
29
+ self._client = AsyncApiClient(base_url=self._base_url)
29
30
 
30
31
  async def __aenter__(self):
31
32
  """Enters the async context and initializes the HTTP client.
@@ -33,7 +34,7 @@ class AsyncRdf4j:
33
34
  Returns:
34
35
  AsyncRdf4j: The initialized RDF4J interface.
35
36
  """
36
- self._client = await AsyncApiClient(base_url=self._base_url).__aenter__()
37
+ self._client = await self._client.__aenter__()
37
38
  return self
38
39
 
39
40
  async def __aexit__(self, exc_type, exc_value, traceback):
@@ -103,7 +104,7 @@ class AsyncRdf4j:
103
104
  RepositoryCreationException: If repository creation fails.
104
105
  """
105
106
  path = f"/repositories/{config.repo_id}"
106
- headers = {"Content-Type": Rdf4jContentType.TURTLE}
107
+ headers = {"Content-Type": Rdf4jContentType.TURTLE.value}
107
108
  response: httpx.Response = await self._client.put(
108
109
  path, content=config.to_turtle(), headers=headers
109
110
  )
@@ -128,3 +129,7 @@ class AsyncRdf4j:
128
129
  raise RepositoryDeletionException(
129
130
  f"Failed to delete repository '{repository_id}': {response.status_code} - {response.text}"
130
131
  )
132
+
133
+ async def aclose(self):
134
+ """Asynchronously closes the client connection."""
135
+ await self._client.aclose()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdf4j-python
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: The Python client for RDF4J
5
5
  Author-email: Chengxu Bian <cbian564@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -20,6 +20,16 @@ async def test_create_repo(
20
20
  assert repos[0].title == random_mem_repo_config.title
21
21
  await db.delete_repository(random_mem_repo_config.repo_id)
22
22
 
23
+ # test without async context manager
24
+ db = AsyncRdf4j(rdf4j_service)
25
+ await db.create_repository(config=random_mem_repo_config)
26
+ repos = await db.list_repositories()
27
+ assert len(repos) == 1
28
+ assert repos[0].id == random_mem_repo_config.repo_id
29
+ assert repos[0].title == random_mem_repo_config.title
30
+ await db.delete_repository(random_mem_repo_config.repo_id)
31
+ await db.aclose()
32
+
23
33
 
24
34
  @pytest.mark.asyncio
25
35
  async def test_delete_repo(
@@ -37,6 +47,18 @@ async def test_delete_repo(
37
47
  repos = await db.list_repositories()
38
48
  assert len(repos) == 0
39
49
 
50
+ # test with out async context manager
51
+ db = AsyncRdf4j(rdf4j_service)
52
+ await db.create_repository(config=random_mem_repo_config)
53
+ repos = await db.list_repositories()
54
+ assert len(repos) == 1
55
+ assert repos[0].id == random_mem_repo_config.repo_id
56
+ assert repos[0].title == random_mem_repo_config.title
57
+ await db.delete_repository(random_mem_repo_config.repo_id)
58
+ repos = await db.list_repositories()
59
+ assert len(repos) == 0
60
+ await db.aclose()
61
+
40
62
 
41
63
  @pytest.mark.asyncio
42
64
  async def test_list_repos(rdf4j_service: str):
File without changes
File without changes
File without changes