caterva2.File#

class caterva2.File(name, root, urlbase, auth_cookie=None)#

A file is either a Blosc2 dataset or a regular file on a root repository.

This is not intended to be instantiated directly, but accessed via a Root instance instead.

Parameters:
  • name (str) – The name of the file.

  • root (str) – The name of the root.

  • urlbase (str) – The base of URLs (slash-terminated) of the subscriber to query.

  • auth_cookie (str) – An optional cookie to authorize requests via HTTP.

Examples

>>> root = cat2.Root('foo')
>>> file = root['README.md']
>>> file.name
'README.md'
>>> file.urlbase
'http://localhost:8002/'
>>> file.path
PosixPath('foo/README.md')
>>> file.meta['cparams']
{'codec': 5, 'typesize': 1, 'blocksize': 32768}
>>> file[:25]
b'This is a simple example,'
>>> file[0]
b'T'
Attributes:
vlmeta

A mapping of metalayer names to their respective values.

Used to access variable-length metalayers (i.e. user attributes) for a file.

>>> root = cat2.Root('foo')
>>> file = root['ds-sc-attr.b2nd']
>>> file.vlmeta
{'a': 1, 'b': 'foo', 'c': 123.456}

Methods

download()

Download a file to storage.

fetch([slice_])

Fetch a slice of a dataset.

get_download_url()

Get the download URL for a file.

__init__(name, root, urlbase, auth_cookie=None)#

Methods

__init__(name, root, urlbase[, auth_cookie])

download()

Download a file to storage.

fetch([slice_])

Fetch a slice of a dataset.

get_download_url()

Get the download URL for a file.

Attributes

vlmeta

A mapping of metalayer names to their respective values.