Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't register berkelydb as a store if it is not available on the system #2096

Merged
merged 5 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,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