How to use the idutils.is_doi function in idutils

To help you get started, we’ve selected a few idutils 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 zenodo / zenodo / zenodo / modules / records / minters.py View on Github external
def zenodo_doi_minter(record_uuid, data):
    """Mint DOI."""
    doi = data.get('doi')
    assert 'recid' in data

    # Create a DOI if no DOI was found.
    if not doi:
        doi = doi_generator(data['recid'])
        data['doi'] = doi

    # Make sure it's a proper DOI
    assert idutils.is_doi(doi)

    # user-provided DOI (external or Zenodo DOI)
    if doi != doi_generator(data['recid']):
        if is_local_doi(doi):
            # User should not provide a custom Zenodo DOI
            # which is not dependent on the recid
            raise PIDValueError('doi', doi)
        else:
            return PersistentIdentifier.create(
                'doi',
                doi,
                object_type='rec',
                object_uuid=record_uuid,
                status=PIDStatus.RESERVED,
            )
    else:  # Zenodo-generated DOI
github inspirehep / inspire-next / inspirehep / modules / references / processors.py View on Github external
def add_uid(self, uid):
        """Add unique identifier in correct field."""
        # We might add None values from wherever. Kill them here.
        uid = uid or ''
        if _is_arxiv(uid):
            self._ensure_reference_field('arxiv_eprint', _normalize_arxiv(uid))
        elif idutils.is_doi(uid):
            self._ensure_reference_field('dois', [])
            self.obj['reference']['dois'].append(idutils.normalize_doi(uid))
        elif idutils.is_handle(uid):
            self._ensure_reference_field('persistent_identifiers', [])
            self.obj['reference']['persistent_identifiers'].append({
                'schema': 'HDL',
                'value': idutils.normalize_handle(uid),
            })
        elif idutils.is_urn(uid):
            self._ensure_reference_field('persistent_identifiers', [])
            self.obj['reference']['persistent_identifiers'].append({
                'schema': 'URN',
                'value': uid,
            })
        elif self.RE_VALID_CNUM.match(uid):
            self._ensure_reference_field('publication_info', {})
github inspirehep / inspire-next / inspirehep / dojson / hep / fields / bd01x09x.py View on Github external
def _is_doi(type_, id_):
        return (not type_ or type_.upper() == 'DOI') and is_doi(id_)
github CERNDocumentServer / cds-videos / cds / modules / records / minters.py View on Github external
def doi_minter(record_uuid, data):
    """Mint DOI."""
    doi = data.get('doi')
    assert 'recid' in data
    assert idutils.is_doi(doi) if doi else True
    
    # Create a DOI if no DOI was found.
    if not doi:
        doi = cds_doi_generator(data['recid'])
        data['doi'] = doi

        # Make sure it's a proper DOI
        assert idutils.is_doi(doi)
        return PersistentIdentifier.create(
            'doi',
            doi,
            pid_provider='datacite',
            object_type='rec',
            object_uuid=record_uuid,
            status=PIDStatus.RESERVED
        )
github CERNDocumentServer / cds-videos / cds / modules / records / minters.py View on Github external
def doi_minter(record_uuid, data):
    """Mint DOI."""
    doi = data.get('doi')
    assert 'recid' in data
    assert idutils.is_doi(doi) if doi else True
    
    # Create a DOI if no DOI was found.
    if not doi:
        doi = cds_doi_generator(data['recid'])
        data['doi'] = doi

        # Make sure it's a proper DOI
        assert idutils.is_doi(doi)
        return PersistentIdentifier.create(
            'doi',
            doi,
            pid_provider='datacite',
            object_type='rec',
            object_uuid=record_uuid,
            status=PIDStatus.RESERVED
        )
github zenodo / zenodo / zenodo / modules / records / serializers / fields / doi.py View on Github external
def _deserialize(self, value, attr, data):
        """Deserialize DOI value."""
        value = super(DOI, self)._deserialize(value, attr, data)
        value = value.strip()
        if value == '' and not (
                self.required or self.context.get('doi_required')):
            return value
        if not idutils.is_doi(value):
            self.fail('invalid_doi')
        return idutils.normalize_doi(value)