caterva2.move#

caterva2.move(src, dst, urlbase=None, auth_cookie=None)#

Moves a dataset or directory to a new location.

Parameters:
  • src (Path) – Source path of the dataset or directory.

  • dst (Path) – The destination path for the dataset or directory.

  • urlbase (str, optional) – Base URL to query. Defaults to caterva2.sub_urlbase_default.

  • auth_cookie (str, optional) – HTTP cookie for authorization. Must be provided unless specified in a :py_obj:`caterva2.c2context`.

Returns:

New path of the moved dataset or directory.

Return type:

str

Examples

>>> import caterva2 as cat2
>>> import numpy as np
>>> # To move a file you need to be a registered used
>>> urlbase = 'https://cat2.cloud/demo'
>>> auth_cookie = cat2.get_auth_cookie(urlbase, dict(username='user@example.com', password='foo'))
>>> path = f'@personal/dir{np.random.randint(0, 100)}/ds-4d.b2nd'
>>> uploaded_path = cat2.upload('root-example/dir2/ds-4d.b2nd', path, urlbase, auth_cookie)
>>> newpath = f'@personal/dir{np.random.randint(0, 100)}/ds-4d-moved.b2nd'
>>> moved_path = cat2.move(path, newpath, urlbase, auth_cookie)
>>> str(moved_path) == newpath
True
>>> path.replace('@personal/', '') in cat2.get_list('@personal', urlbase, auth_cookie)
False