Skip to content

Commit

Permalink
fix: Don't register berkelydb as a store if it is not available on th…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
eden-logistics committed Aug 23, 2022
1 parent c487be6 commit 04bf774
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,24 @@ and will be removed for release.
<!-- -->
<!-- -->


<!-- -->
<!-- -->
<!-- CHANGE BARRIER: START -->
<!-- -->
<!-- -->

- Only register the `rdflib.plugins.stores.berkeleydb.BerkeleyDB` as a store
plugin if the `berkeleydb` module is present.
Closed [issue #1816](https://github.com/RDFLib/rdflib/issues/1816).
[PR #2096](https://github.com/RDFLib/rdflib/pull/2096).

<!-- -->
<!-- -->
<!-- CHANGE BARRIER: END -->
<!-- -->
<!-- -->

<!-- -->
<!-- -->
<!-- CHANGE BARRIER: START -->
Expand Down
17 changes: 11 additions & 6 deletions rdflib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
overload,
)

import rdflib.plugins.stores.berkeleydb
from rdflib.exceptions import Error
from rdflib.parser import Parser
from rdflib.query import (
Expand Down Expand Up @@ -179,6 +180,15 @@ def plugins(


# Register Stores

if rdflib.plugins.stores.berkeleydb.has_bsddb:
# Checks for BerkeleyDB before registering it
register(
"BerkeleyDB",
Store,
"rdflib.plugins.stores.berkeleydb",
"BerkeleyDB",
)
register(
"default",
Store,
Expand Down Expand Up @@ -209,12 +219,7 @@ def plugins(
"rdflib.plugins.stores.concurrent",
"ConcurrentStore",
)
register(
"BerkeleyDB",
Store,
"rdflib.plugins.stores.berkeleydb",
"BerkeleyDB",
)

register(
"SPARQLStore",
Store,
Expand Down
3 changes: 0 additions & 3 deletions test/test_graph/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from rdflib.exceptions import ParserError
from rdflib.namespace import Namespace, NamespaceManager
from rdflib.plugin import PluginException
from rdflib.plugins.stores.berkeleydb import has_bsddb
from rdflib.store import Store
from rdflib.term import BNode

Expand Down Expand Up @@ -75,8 +74,6 @@ def get_store_names() -> Set[Optional[str]]:
}
)
names.add(None)
if not has_bsddb:
names.remove("BerkeleyDB")

logging.debug("names = %s", names)
return names
Expand Down

0 comments on commit 04bf774

Please sign in to comment.