Formatted with Ruff

This commit is contained in:
Richard Bowman 2024-12-03 06:46:08 +00:00
parent 27aec769a2
commit 9fd8fc37f1
19 changed files with 680 additions and 392 deletions

View file

@ -5,6 +5,7 @@ Copyright (c) 2018 German Aerospace Center (DLR). All rights reserved.
SPDX-License-Identifier: MIT-DLR
"""
import json
import os
@ -21,7 +22,7 @@ class Zenodo:
self.zenodo_url = "https://zenodo.org/api/deposit/depositions"
def create_new_deposit(self):
""" Creates a new (unpublished) Zenodo deposit and return its deposition ID. """
"""Creates a new (unpublished) Zenodo deposit and return its deposition ID."""
headers = {"Content-Type": "application/json"}
r = requests.post(
@ -35,7 +36,7 @@ class Zenodo:
return r.json()
def set_metadata(self, deposition_id, metadata):
""" Sets the given metadata for the specified deposit. """
"""Sets the given metadata for the specified deposit."""
headers = {"Content-Type": "application/json"}
r = requests.put(
@ -48,7 +49,7 @@ class Zenodo:
print(r.json())
def upload_file(self, deposition_id, file_path):
""" Uploads a new file for the given deposit. """
"""Uploads a new file for the given deposit."""
file_name = os.path.basename(file_path)
data = {"filename": file_name}
@ -63,7 +64,7 @@ class Zenodo:
print(r.json())
def publish_deposit(self, deposition_id):
""" Publishes the given deposit. BEWARE: It is now visible to all!!! """
"""Publishes the given deposit. BEWARE: It is now visible to all!!!"""
r = requests.post(
self.zenodo_url + "/{}/actions/publish".format(deposition_id),
@ -73,7 +74,7 @@ class Zenodo:
print(r.json())
def create_new_version(self, deposition_id):
""" Creates a new version of an already published deposit. """
"""Creates a new version of an already published deposit."""
r = requests.post(
self.zenodo_url + "/{}/actions/newversion".format(deposition_id),
@ -84,7 +85,7 @@ class Zenodo:
return os.path.basename(r.json()["links"]["latest_draft"])
def remove_all_files(self, deposition_id):
""" Removes all uploaded files of a unpublished deposit. """
"""Removes all uploaded files of a unpublished deposit."""
r = requests.get(
self.zenodo_url + "/{}/files".format(deposition_id),