Module zenodo_helper

zenodo_helper.check_token(base_url, token)

Function to check if Zenodo token is allowed to deposit files

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

zenodo_helper.creator_dict(df, i, contact_file='')

Format Creator field to dict. Add orcid from contact file (geoflow format) Replace email with name

Parameters:
  • df (class 'pandas.core.frame.DataFrame') – Pandas dataframe from metadata entities (geoflow format)

  • i (int) – Line of metadata entities

  • contact_file (str) – Filename containing contacts (geoflow format)

e.g.:

“creators”: [{ “orcid”: “0000-0002-1825-0097”, “affiliation”: “Feline reasearch institute”, “name”: “Field, Gar” }, { “orcid”: “0000-0002-1825-0097”, “affiliation”: “Feline reasearch institute”, “name”: “Cat, Felix” }],

zenodo_helper.zen_del_file(url, token)

Delete file on zenodo platform

Parameters:
  • url (str) – url of zenodo file

  • token (str) – zenodo access token

zenodo_helper.zen_latest(base_url, token, record_id)

Return latest record_id of query record

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – Zenodo record id

  • e.g.

  • record (# List of latest)

  • zenlist_all("https (//zenodo.org/api", token))

zenodo_helper.zen_newversion(base_url, token, record_id)

Create a new DOI version

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – zenodo record id

zenodo_helper.zen_registerid(base_url, token, record_id)

Register conceptdoi from draft

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – Zenodo record id

  • e.g.

  • records (# List of)

  • zenlist_single("https (//zenodo.org/api", token, 10064384))

zenodo_helper.zen_unlock_submited(base_url, token, record_id)

Unlock published version to update metadata

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – zenodo record id

zenodo_helper.zenedit(base_url, token, record_id)

Unlock published version to update metadata

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – zenodo record id

zenodo_helper.zenfiles(base_url, token, record_id)

Retrieve uploaded files

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – zenodo record id

zenodo_helper.zenlist_all(base_url, token)

Return list of all Zenodo records

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • e.g.

  • records (# List of)

  • zenlist_all("https (//zenodo.org/api", token))

zenodo_helper.zenlist_all_query(base_url, token, query)

Return list of all Zenodo records and a query

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • query (str) – keyword you want to look for

  • e.g.

  • keywords (# List of records with)

  • zenlist_all_query("https (//zenodo.org/api", token, "G2OI"))

zenodo_helper.zenlist_single(base_url, token, record_id)

Return details of one Zenodo record

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – Zenodo record id

  • e.g.

  • record (# Details of single)

  • zenlist_single("https (//zenodo.org/api", token, 10064384))

zenodo_helper.zenlist_single_files(base_url, token, record_id)

Return files of one Zenodo record

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – Zenodo record id

  • e.g.

  • files (# List of)

  • zenlist_single("https (//zenodo.org/api", token, 10064384))

zenodo_helper.zenmdt(base_url, token, record_id, df, i, contact_file='')

Set and fill Metadata from Dataframe

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – zenodo record id

  • df (class 'pandas.core.frame.DataFrame') – Pandas dataframe from metadata entities (geoflow format)

  • i (int) – Line of metadata entities

  • contact_file (str) – Filename containing contacts (geoflow format)

zenodo_helper.zenodo_json(fname, type, output, out_prefix)

JSON configuration for Zenodo with optionnal type parameter if type is not defined, regular zenodo will be use. if type=’sandbox’: Zenodo Sandbox will be use !

Parameters:
  • fname (str) – file name

  • type (str) – regular zenodo or zenodo sandbox

  • output (str) – output folder

  • out_prefix (str) – name in front of file name, usually date and hour

zenodo_helper.zenpublish(base_url, token, record_id)

Publish record !

Parameters:
  • base_url (str) – url of zenodo or zenodo sandbox without trailing ‘/’

  • token (str) – zenodo access token

  • record_id (str) – zenodo record id

zenodo_helper.zenul(bucket_url, token, folder, filename)

Upload new files to Zenodo The target URL is a combination of the base url with records, record_id and files seperated by a slash. folder: str

Parameters:
  • bucket_url (str) – Zenodo bucket url

  • token (str) – Zenodo token

  • filename (list) – Filename to upload

zenodo_helper.zenul2(base_url, record_id, token, folder, filename)

Upload new files to Zenodo The target URL is a combination of the base url with records, record_id and files seperated by a slash. folder: str

Parameters:
  • base_url (str) – Zenodo base url ended by /

  • record_id (str) – Zenodo record id. Also answered from zenvar[-1] Folder path where your archive is available

  • filename (list) – Filename to upload

zenodo_helper.zenvar(requests_response)

Store 3 variables in a list: - bucket_url - Reserved DOI - Record id from check_token function

Parameters:

requests_response (Python requests.Response Object) – answer from check_token