fairops.repositories package

fairops.repositories.figshare module

class fairops.repositories.figshare.FigshareClient(api_token: str)[source]

Bases: object

A client for interacting with the Figshare API to manage projects, articles, and file uploads/downloads.

Initialize the Figshare client with an API token.

Args:

api_token (str): The Figshare API token for authentication.

create_article_in_project(project_id: int, title: str) int[source]

Create a new article within a Figshare project.

Args:

project_id (int): The Figshare project ID. title (str): The title of the article.

Returns:

int: The newly created article ID.

create_project(title: str, description: str) int[source]

Create a new project on Figshare.

Args:

title (str): The title of the project. description (str): A description of the project.

Returns:

int: The newly created project ID.

delete_article(article_id: int)[source]
delete_project(project_id: int)[source]
download_files_by_doi(doi: str, output_path: str) str[source]

Download files using a Figshare DOI.

Args:

doi (str): The DOI of the Figshare article. output_path (str): Local directory to save downloaded files.

Returns:

str: Path to the downloaded files, or None if the article is not found.

download_files_by_id(article_id: int, output_path: str, private=False) str[source]

Download all files associated with an article.

Args:

article_id (int): The Figshare article ID. output_path (str): Local directory to save downloaded files.

Returns:

str: Path to the downloaded files.

upload_files_to_project(project_id: int, title: str, file_paths: list)[source]

Upload multiple files to a Figshare project.

Args:

project_id (int): The Figshare project ID. title (str): The article title. file_paths (list): List of file paths to upload.

fairops.repositories.zenodo module

class fairops.repositories.zenodo.FileWithProgress(file_path, desc=None)[source]

Bases: object

close()[source]
read(size=-1)[source]
class fairops.repositories.zenodo.ZenodoClient(api_token: str)[source]

Bases: object

A client for interacting with the Zenodo API to manage projects, articles, and file uploads/downloads.

Initialize the Zenodo client with an API token.

Args:

api_token (str): The Zenodo API token for authentication.

create_project(title: str, description: str)[source]

Create a draft record in Zenodo.

download_files_by_doi(doi, download_dir)[source]

Download all files from a Zenodo record given its DOI.

download_files_by_id(record_id, download_path, private=False)[source]

Download a file from Zenodo.

upload_files_to_project(project_id, file_paths, title=None)[source]

Upload a large file to Zenodo draft using PUT (streaming upload).