feat: add support for .b2z, .b2d, .b2e files and update related tests #541
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support special stores in
blosc2.open()and add context managersThis PR enhances
blosc2.open()to support openingDictStoreandEmbedStorefiles directly via file extensions. It also implements context manager support for these stores and refactors theopen()function to improve code maintainability.Key Changes:
Unified
blosc2.open()API:DictStorefiles with extensions.b2zand.b2dEmbedStorefiles with extension.b2eblosc2.open("data.b2z")instead of importing specific store classesRefactoring (Code Quality):
src/blosc2/schunk.py:open()to address high cyclomatic complexity (Ruff C901) triggered by changes introduced by this commit_open_special_store(): Handles extension-based dispatch for special stores_set_default_dparams(): Centralizes default decompression parameter logic_process_opened_object(): Handles post-open logic forProxyandLazyArrayContext Manager Support:
__enter__(),__exit__(), andclose()methods forDictStoreandEmbedStorewithstatement for safer resource management (e.g.,with blosc2.open("file.b2z") as store:)Bug Fixes:
DictStoreandEmbedStoreinternally calledblosc2.open(), creating a loop. These now use the lower-levelblosc2_ext.open()Testing:
test_open_context_manager()totests/test_dict_store.pyandtests/test_embed_store.pyto verify the new functionality