Skip to content

Commit

Permalink
#Fixes NaturalHistoryMuseum#100: Update to schema43
Browse files Browse the repository at this point in the history
  • Loading branch information
t-book authored Mar 13, 2024
1 parent 59942cf commit 969ac97
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ckanext/doi/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ckan.common import asbool
from ckan.plugins import toolkit
from ckanext.doi.model.crud import DOIQuery
from datacite import DataCiteMDSClient, schema42
from datacite import DataCiteMDSClient, schema43
from datacite.errors import DataCiteError, DataCiteNotFoundError
from datetime import datetime as dt

Expand Down Expand Up @@ -139,9 +139,9 @@ def set_metadata(self, doi, xml_dict):
xml_dict['identifiers'] = [{'identifierType': 'DOI', 'identifier': doi}]

# check that the data is valid, this will raise a JSON schema exception if there are issues
schema42.validator.validate(xml_dict)
schema43.validator.validate(xml_dict)

xml_doc = schema42.tostring(xml_dict)
xml_doc = schema43.tostring(xml_dict)
# create the metadata on datacite
self.client.metadata_post(xml_doc)

Expand Down Expand Up @@ -170,7 +170,7 @@ def check_for_update(self, doi, xml_dict):
if posted_xml is None or posted_xml.strip() == '':
return False
posted_xml_dict = dict(xmltodict.parse(posted_xml).get('resource', {}))
new_xml_dict = dict(xmltodict.parse(schema42.tostring(xml_dict))['resource'])
new_xml_dict = dict(xmltodict.parse(schema43.tostring(xml_dict))['resource'])
if 'identifier' in posted_xml_dict:
del posted_xml_dict['identifier']
has_dates = 'dates' in posted_xml_dict and 'date' in posted_xml_dict['dates']
Expand Down

0 comments on commit 969ac97

Please sign in to comment.