DecodedView#
- class barecat.DecodedView(store)[source]#
Bases:
collections.abc.MutableMapping[str,Any]Dict-like view that always encodes/decodes based on file extension.
Wraps a raw bytes store (like Barecat) and automatically encodes on write and decodes on read based on the file extension. Raises an error if no codec is registered for the extension.
- Parameters:
store (MutableMapping[str, bytes]) – A MutableMapping[str, bytes] to wrap (e.g., a Barecat instance).
Examples
>>> bc = Barecat('data.barecat', readonly=False) >>> dec = DecodedView(bc) >>> dec['config.json'] = {'key': 'value'} >>> dec['config.json'] {'key': 'value'} >>> dec['image.png'] = numpy_array >>> # For raw bytes, use the store directly: bc['data.raw'] = b'...'
Instance Methods#
|
Register a codec for the given extensions. |
Remove all registered codecs. |
|
|
D.keys() -> a set-like object providing a view on D's keys |
|
D.items() -> a set-like object providing a view on D's items |
|
D.values() -> an object providing a view on D's values |