Skip to content

Commit 04bf774

Browse files
fix: Don't register berkelydb as a store if it is not available on the system (#2096)
This is so that it is simpler and easier to do something with all plugins without treating different plugins in different ways. Also remove test code that tries to accommodate the plugin being present but not usable. Fixes #1816
1 parent c487be6 commit 04bf774

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,24 @@ and will be removed for release.
291291
<!-- -->
292292
<!-- -->
293293

294+
295+
<!-- -->
296+
<!-- -->
297+
<!-- CHANGE BARRIER: START -->
298+
<!-- -->
299+
<!-- -->
300+
301+
- Only register the `rdflib.plugins.stores.berkeleydb.BerkeleyDB` as a store
302+
plugin if the `berkeleydb` module is present.
303+
Closed [issue #1816](https://github.com/RDFLib/rdflib/issues/1816).
304+
[PR #2096](https://github.com/RDFLib/rdflib/pull/2096).
305+
306+
<!-- -->
307+
<!-- -->
308+
<!-- CHANGE BARRIER: END -->
309+
<!-- -->
310+
<!-- -->
311+
294312
<!-- -->
295313
<!-- -->
296314
<!-- CHANGE BARRIER: START -->

rdflib/plugin.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
overload,
4040
)
4141

42+
import rdflib.plugins.stores.berkeleydb
4243
from rdflib.exceptions import Error
4344
from rdflib.parser import Parser
4445
from rdflib.query import (
@@ -179,6 +180,15 @@ def plugins(
179180

180181

181182
# Register Stores
183+
184+
if rdflib.plugins.stores.berkeleydb.has_bsddb:
185+
# Checks for BerkeleyDB before registering it
186+
register(
187+
"BerkeleyDB",
188+
Store,
189+
"rdflib.plugins.stores.berkeleydb",
190+
"BerkeleyDB",
191+
)
182192
register(
183193
"default",
184194
Store,
@@ -209,12 +219,7 @@ def plugins(
209219
"rdflib.plugins.stores.concurrent",
210220
"ConcurrentStore",
211221
)
212-
register(
213-
"BerkeleyDB",
214-
Store,
215-
"rdflib.plugins.stores.berkeleydb",
216-
"BerkeleyDB",
217-
)
222+
218223
register(
219224
"SPARQLStore",
220225
Store,

test/test_graph/test_graph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from rdflib.exceptions import ParserError
1414
from rdflib.namespace import Namespace, NamespaceManager
1515
from rdflib.plugin import PluginException
16-
from rdflib.plugins.stores.berkeleydb import has_bsddb
1716
from rdflib.store import Store
1817
from rdflib.term import BNode
1918

@@ -75,8 +74,6 @@ def get_store_names() -> Set[Optional[str]]:
7574
}
7675
)
7776
names.add(None)
78-
if not has_bsddb:
79-
names.remove("BerkeleyDB")
8077

8178
logging.debug("names = %s", names)
8279
return names

0 commit comments

Comments
 (0)