frame_cli.downloaders.zenodo module

Module containing the ZenodoDownloader class.

class frame_cli.downloaders.zenodo.ZenodoDownloader[source]

Bases: Downloader

Downloader for Zenodo repositories.

_abc_impl = <_abc._abc_data object>
download(url: str, *args, destination: str | None = None, **kwargs) str[source]

Download the content at the given URL.

Parameters:
  • url (str) – URL of the content to download.

  • destination (str) – Destination directory to save the content to. Defaults to None, which creates a new directory from the repository name.

Returns:

The destination directory.

Return type:

str

exception frame_cli.downloaders.zenodo.ZenodoError[source]

Bases: Exception

Custom exception for Zenodo errors.

frame_cli.downloaders.zenodo._check_request_response(response: Response, task_description: str, expected_status: int = 200) None[source]

Check the status of the given request.

Parameters:
  • response (requests.Response) – Response object from the request.

  • task_description (str) – Description of the task being performed.

  • expected_status (int) – Expected status code. Defaults to 200.

Raises:

ZenodoError – The request failed.

frame_cli.downloaders.zenodo._download_file(url: str, key: str, path: str, progress: Progress, task_id: TaskID) None[source]

Download the file from the given URL.

Parameters:
  • url (str) – URL of the file to download.

  • key (str) – Name of the file.

  • path (str) – Path to save the file to.

  • progress (Progress) – Rich progress tracker.

  • task_id (TaskID) – Rich task ID.

frame_cli.downloaders.zenodo._download_files(record: dict, destination: str) None[source]

Download all files from the given Zenodo record.

Parameters:
  • record (dict) – Zenodo record information.

  • destination (str) – Destination directory to save the files to.

frame_cli.downloaders.zenodo._get_host_and_id_from_url(url: str) tuple[str, str][source]

Get the host and study ID from the given URL.

Parameters:

url (str) – URL to parse, ending in “10.XXXX/zenodo.[ID]”.

Returns:

Either “zenodo.org” or “sandbox.zenodo.org”. id (str): Dataset ID extracted from the DOI.

Return type:

host (str)

Raises:

ValueError – The URL is not a valid Zenodo DOI or URL.

frame_cli.downloaders.zenodo.handle_sigint(sig, frame)[source]