Skip to content

Instantly share code, notes, and snippets.

@mmichealjroberts
Created August 14, 2020 08:06
Show Gist options
  • Save mmichealjroberts/600cc56041f3dbcf8733a75d06e949de to your computer and use it in GitHub Desktop.
Save mmichealjroberts/600cc56041f3dbcf8733a75d06e949de to your computer and use it in GitHub Desktop.
def serialize_dataset_to_doi(dataset: DatasetStorePointer) -> Dict[str, Any]:
return {
"data": {
"type": "dois",
"attributes": {
"doi": dataset.doi,
"prefix": settings.DATACITE['DOI_PREFIX'],
"suffix": dataset.doi_suffix,
"event": "publish",
"creators": dataset.creators if dataset.creators else [],
"titles": [
{
"title": dataset.name
}
],
"publisher": "asencis",
"container": {},
"publicationYear": dataset.publication_date.year,
"subjects": [],
"contributors": dataset.contributors if dataset.contributors else [],
"types": {
"resourceTypeGeneral": dataset.type,
},
"relatedIdentifiers": [],
"sizes": [
dataset.file_entity.size
],
"formats": [
dataset.format
],
"descriptions": [
{
"description": dataset.abstract,
"descriptionType": "Abstract"
},
{
"description": dataset.technical_information,
"descriptionType": "TechnicalInfo"
},
{
"description": dataset.supplementary_information,
"descriptionType": "Other"
}
],
"geoLocations": [],
"fundingReferences": [],
"url": 'https://asencis.com/datasets/{}'.format(dataset.uuid),
"schemaVersion": "http://datacite.org/schema/kernel-4",
"isActive": True,
"state": "findable",
"reason": None
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment