datalight package¶
Submodules¶
datalight.common module¶
This module is common core functions for datalight.
-
datalight.common.
get_authentication_token
(sandbox)[source]¶ A method to read the Zenodo authentication token from a local file. This file is not committed to git and so will not appear online.
-
datalight.common.
get_files_path
(directory_name)[source]¶ Recursively collect file paths within the given directory.
The function will return a list of file paths relative to directory_name. :param directory_name: (str) The path to a directory :return files_paths: (list of string) Paths of files relative to directory_name. :raises FileNotFoundError: if the directory does not exist.
datalight.main module¶
Main module for datalight.
datalight.zenodo module¶
This module is implements high level functions to upload and download data to Zenodo.
-
class
datalight.zenodo.
Zenodo
(token, metadata_path, sandbox=False)[source]¶ Bases:
object
Class to upload and download files on Zenodo The deposit record method should be called and this does all of the steps required to uplad a file.
Variables: - token – (str) API token for connection to Zenodo.
- sandbox – (bool) If True, upload to the Zenodo sandbox. If false, upload to Zenodo.
-
delete
(_id=None)[source]¶ Method to delete an unpublished deposition. If id not provided, use self.deposition_id, else use provided id
Parameters: _id – (int) Deposition id of the record to delete. Can be done only if the record was not published.
Raises: ZenodoException – If connection return status >= 400
-
deposit_record
(files, directory, publish)[source]¶ The main method which calls the many parts of the upload process.
-
publish
()[source]¶ Method which will publish the deposition linked with the id.
Raises: ZenodoException – Raise if connection return status >= 400
datalight.zenodo_metadata module¶
This module processes and validates metadata.
-
class
datalight.zenodo_metadata.
ZenodoMetadata
[source]¶ Bases:
object
Class to manage the Metadata needed for a Zenodo upload.
general schema for usage is: set_schema() set_metadata() validate_metadata()
-
set_metadata
(metadata_path)[source]¶ Method to set metadata from a file.
Parameters: metadata_path – (path) A path to a file which contains zenodo metadata (yaml format).
-