Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _is_handle(type_, id_):
return (not type_ or type_.upper() in ('DOI', 'HDL')) and is_handle(id_)
def _is_handle(id_, type_):
return (not type_ or type_.upper() == 'HDL') and is_handle(id_)
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', {})
self.obj['reference']['publication_info']['cnum'] = uid
else:
# idutils.is_isbn has a different implementation than normalize