caterva2.Dataset.copy#

Dataset.copy(dst)#

Copy a file to a new location.

Parameters:

dst (Path) – The destination path of the file.

Returns:

The new path of the file.

Return type:

Path

Examples

>>> import caterva2 as cat2
>>> import numpy as np
>>> # For copying a file you need to be a registered user
>>> urlbase = 'https://cat2.cloud/demo'
>>> root = cat2.Root('@personal', urlbase, dict(username='user@example.com', password='foo'))
>>> root.upload('root-example/dir2/ds-4d.b2nd')
<Dataset: @personal/root-example/dir2/ds-4d.b2nd>
>>> auth_cookie = cat2.get_auth_cookie(urlbase, dict(username='user@example.com', password='foo'))
>>> file = cat2.File('root-example/dir2/ds-4d.b2nd', '@personal', urlbase, auth_cookie)
>>> file.copy('@personal/root-example/dir2/ds-4d-copy.b2nd')
PosixPath('@personal/root-example/dir2/ds-4d-copy.b2nd')
>>> 'root-example/dir2/ds-4d.b2nd' in root
True
>>> 'root-example/dir2/ds-4d-copy.b2nd' in root
True