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

Wrapper arg fix #15

Merged
merged 1 commit into from
Aug 29, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = cloud-mappings
version = 1.2.0
version = 1.2.1
author = Lucas Sargent
author_email = lucas.sargent@outlook.com
description = MutableMapping interfaces for common cloud storage providers
Expand Down
18 changes: 11 additions & 7 deletions src/cloudmappings/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import inspect

from .cloudstoragemapping import CloudMapping


def _parse_cloud_mapping_kwargs(kwargs: dict):
cloud_mapping_kwargs = dict(
sync_initially=kwargs.pop("sync_initially", True),
read_blindly=kwargs.pop("read_blindly", False),
read_blindly_default=kwargs.pop("read_blindly_default", None),
ordered_dumps_funcs=kwargs.pop("ordered_dumps_funcs", None),
ordered_loads_funcs=kwargs.pop("ordered_loads_funcs", None),
)
# We inspect the CloudMapping.__init__ function to determine what kwargs
# it understands, and pull those out. The remaining kwargs are then passed
# to the storage provider.
cloud_mapping_kwargs = {
n: kwargs.pop(n) if n in kwargs else p.default
for n, p in inspect.signature(CloudMapping.__init__).parameters.items()
if n not in ["self", "storage_provider"]
}
print(cloud_mapping_kwargs)
return cloud_mapping_kwargs, kwargs


Expand Down
8 changes: 8 additions & 0 deletions tests/tests/5_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def test_azure_blob_mapping(self, azure_blob_storage_account_url, test_container
container_name=test_container_name,
sync_initially=False,
read_blindly=True,
read_blindly_error=False,
read_blindly_default=None,
)
assert len(cm.etags) == 0
assert cm.read_blindly == True
Expand All @@ -32,6 +34,8 @@ def test_azure_table_mapping(self, azure_table_storage_connection_string, test_c
table_name=test_container_name,
sync_initially=False,
read_blindly=True,
read_blindly_error=False,
read_blindly_default=None,
)
assert len(cm.etags) == 0
assert cm.read_blindly == True
Expand All @@ -51,6 +55,8 @@ def test_gcp_storage_mapping(self, gcp_storage_project, test_container_name):
bucket_name=test_container_name,
sync_initially=False,
read_blindly=True,
read_blindly_error=False,
read_blindly_default=None,
)
assert len(cm.etags) == 0
assert cm.read_blindly == True
Expand All @@ -69,6 +75,8 @@ def test_aws_s3_mapping(self, test_container_name):
bucket_name=test_container_name,
sync_initially=False,
read_blindly=True,
read_blindly_error=False,
read_blindly_default=None,
)
assert len(cm.etags) == 0
assert cm.read_blindly == True
Expand Down