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

Implement _from_parsed_url for (H)DictStore and add test #84

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Changelog

1.8.0
=====
* Implemented the ``_from_parsed_url`` for the following stores:
* ``DictStore`` and ``HDictStore``
* Fixed the behaviour of ``S3FSStore`` when providing a custom endpoint.
* Added ``verify`` constructor argument to ``S3FSStore`` that disables SSL verification. Use it in an URI as ``?verify=false``.

Expand Down
10 changes: 6 additions & 4 deletions minimalkv/_get_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from uritools import SplitResult, urisplit

from minimalkv._key_value_store import KeyValueStore
from minimalkv._urls import url2dict


def get_store_from_url(
Expand Down Expand Up @@ -53,13 +52,16 @@ def get_store_from_url(
See the respective store's :func:`_from_parsed_url` function for more details.

"""
from minimalkv._hstores import HS3FSStore
from minimalkv._hstores import HDictStore, HS3FSStore
from minimalkv.memory import DictStore
from minimalkv.net.s3fsstore import S3FSStore

scheme_to_store: Dict[str, Type[KeyValueStore]] = {
"s3": S3FSStore,
"hs3": HS3FSStore,
"boto": HS3FSStore,
"memory": DictStore,
"hmemory": HDictStore,
}

parsed_url = urisplit(url)
Expand All @@ -73,8 +75,8 @@ def get_store_from_url(
scheme = scheme_parts[0]

if scheme not in scheme_to_store:
# If we can't find the scheme, we fall back to the old creation methods
return get_store(**url2dict(url))
# If we can't find the scheme, we fail hard.
raise NotImplementedError(scheme)

store_cls_from_url = scheme_to_store[scheme]
if store_cls is not None and store_cls_from_url != store_cls:
Expand Down