Commit 46e9fdef authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Functionality to update all DOI urls at datacite.

parent 9db663a2
......@@ -27,6 +27,22 @@ from nomad.datamodel import User
from nomad import config, utils
def edit_url(doi: str, url: str = None):
""" Changes the URL of an already findable DOI. """
if url is None:
url = '' % doi
metadata_url = '%s/doi/%s' % (config.datacite.mds_host, doi)
response = requests.put(
headers={'Content-Type': 'text/plain;charset=UTF-8'},
data='doi=%s\nurl=%s' % (doi, url), **_requests_args())
if response.status_code >= 300:
raise Exception('Unexpected datacite response (status code %d): %s' % (
response.status_code, response.text))
def _xml(parent, element: str, value: str = None):
path = element.split('/')
el = parent
from nomad import doi, infrastructure, utils
from nomad.datamodel import Dataset
if __name__ == '__main__':
for dataset in Dataset.m_def.m_x('me').objects(doi__exists=True):
except Exception as e:
utils.get_logger('__name__').error('could not rewrite doi', exc_info=e)
print('Rewrote URL of %s' % dataset.doi)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment