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 of the subscriber to query. Default is
caterva2.sub_urlbase_default
.auth_cookie¶ (str) – An optional cookie to authorize requests via HTTP. For some actions this must be specified unless it was already specified inside a :py_obj:`caterva2.c2context`.
Examples
>>> import caterva2 as cat2 >>> root = cat2.Root('example', 'https://demo.caterva2.net') >>> file = root['README.md'] >>> file <File: example/README.md> >>> file.name 'README.md' >>> file.urlbase 'https://demo.caterva2.net' >>> file.path PosixPath('example/README.md') >>> file.meta['contiguous'] True
- Attributes:
- vlmeta
A mapping of metalayer names to their respective values.
Used to access variable-length metalayers (i.e. user attributes) for a file.
>>> import caterva2 as cat2 >>> root = cat2.Root('example', 'https://demo.caterva2.net') >>> file = root['ds-sc-attr.b2nd'] >>> file.vlmeta {'a': 1, 'b': 'foo', 'c': 123.456}
Methods
copy
(dst)Copy a file to a new location.
download
([localpath])Download a file to storage.
fetch
([slice_])Fetch a slice of a dataset.
Get the download URL for a file.
move
(dst)Move a file to a new location.
remove
()Remove a file from a remote repository.
- __init__(name, root, urlbase, auth_cookie=None)#
Methods
__init__
(name, root, urlbase[, auth_cookie])copy
(dst)Copy a file to a new location.
download
([localpath])Download a file to storage.
fetch
([slice_])Fetch a slice of a dataset.
Get the download URL for a file.
move
(dst)Move a file to a new location.
remove
()Remove a file from a remote repository.
Attributes
A mapping of metalayer names to their respective values.