How to use the datacite.client.DataCiteMDSClient function in datacite

To help you get started, we’ve selected a few datacite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github galterlibrary / InvenioRDM-at-NU / cd2h_repo_project / modules / doi / tasks.py View on Github external
`default_retry_delay` is in seconds.

    :param recid_pid_value: pid_value of recid-PID for the target record.
                            Note that this pid_value is also the pid_value of
                            the doi-PID associated with the target record if
                            it has not been DOI-minted yet.
    """
    try:
        recid_pid, record = record_resolver.resolve(str(recid_pid_value))
        depid_pid, deposit = Deposit.fetch_deposit(record)

        doi_pid_value = record.get('doi') or recid_pid_value
        doi_pid = PersistentIdentifier.get(
            pid_type='doi', pid_value=doi_pid_value)

        client = DataCiteMDSClient(
            username=current_app.config['PIDSTORE_DATACITE_USERNAME'],
            password=current_app.config['PIDSTORE_DATACITE_PASSWORD'],
            prefix=current_app.config['PIDSTORE_DATACITE_DOI_PREFIX'],
            test_mode=current_app.config['PIDSTORE_DATACITE_TESTMODE'],
            url=current_app.config['PIDSTORE_DATACITE_URL']
        )

        # Update DataCite metadata and let DataCite mint new DOI if unknown DOI
        serialized_record = datacite_v41.serialize(doi_pid, record)
        result = client.metadata_post(serialized_record)
        minted_doi = extract_doi(result)

        if not RecordPermissions.is_private(record):
            landing_url = url_for_record_ui_recid_external(recid_pid_value)
            client.doi_post(minted_doi, landing_url)