caterva2.File#
- class caterva2.File(name, root, urlbase, auth_cookie=None)#
Represents a file, which can be a Blosc2 dataset or a regular file on a root repository.
This class is not intended for direct instantiation; it should be accessed through a
Root
instance.- Parameters:
name¶ (str) – The name of the file.
root¶ (str) – The name of the root repository.
urlbase¶ (str, optional) – Base URL for querying the subscriber. Defaults to
caterva2.sub_urlbase_default
.auth_cookie¶ (str, optional) – An optional cookie for HTTP request authorization. This must be specified for certain actions unless already provided in 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
Returns a mapping of metalayer names to their respective values.
This is used to access variable-length metalayers (user attributes) associated with the 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)Copies the file to a new location.
download
([localpath])Downloads the file to storage.
fetch
([slice_])Fetches a slice of the dataset.
Retrieves the download URL for the file.
move
(dst)Moves the file to a new location.
remove
()Removes the file from the remote repository.
- __init__(name, root, urlbase, auth_cookie=None)#
Methods
__init__
(name, root, urlbase[, auth_cookie])copy
(dst)Copies the file to a new location.
download
([localpath])Downloads the file to storage.
fetch
([slice_])Fetches a slice of the dataset.
Retrieves the download URL for the file.
move
(dst)Moves the file to a new location.
remove
()Removes the file from the remote repository.
Attributes
Returns a mapping of metalayer names to their respective values.