asteroid.models.zenodo module¶
-
class
asteroid.models.zenodo.
Zenodo
(api_key=None, use_sandbox=True)[source]¶ Bases:
object
Faciliate Zenodo’s REST API.
Parameters: - Methods (all methods return the requests response):
- create_new_deposition change_metadata_in_deposition, upload_new_file_to_deposition publish_deposition get_deposition remove_deposition remove_all_depositions
Note
A Zenodo record is something that is public and cannot be deleted. A Zenodo deposit has not yet been published, is private and can be deleted.
-
change_metadata_in_deposition
(dep_id, metadata)[source]¶ Set or replace metadata in given deposition
Parameters: Examples
- metadata = {
‘title’: ‘My first upload’, ‘upload_type’: ‘poster’, ‘description’: ‘This is my first upload’, ‘creators’: [{‘name’: ‘Doe, John’,
‘affiliation’: ‘Zenodo’}]
}
-
create_new_deposition
(metadata=None)[source]¶ Creates a new deposition.
Parameters: metadata (dict, optional) – Metadata dict to upload on the new deposition.
-
publish_deposition
(dep_id)[source]¶ Publish given deposition (Cannot be deleted)!
Parameters: dep_id (int) – deposition id. You cna get it with r = create_new_deposition(); dep_id = r.json()[‘id’]
-
upload_new_file_to_deposition
(dep_id, file, name=None)[source]¶ Upload one file to existing deposition. :param dep_id: deposition id. You cna get it with
r = create_new_deposition(); dep_id = r.json()[‘id’]Parameters: - file (str or io.BufferedReader) – path to a file, or already opened file (path prefered).
- name (str, optional) – name given to the uploaded file. Defaults to the path.