Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'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
# isbn. Better to do it like this.
try:
isbn = idutils.normalize_isbn(uid)
self._ensure_reference_field('isbn', {})
self.obj['reference']['isbn'] = isbn.replace(' ', '').replace('-', '')
# See https://github.com/nekobcn/isbnid/issues/2 and
# https://github.com/nekobcn/isbnid/issues/3 for understanding the
# long exception list.
except (ISBNError, ISBNRangeError, UnicodeEncodeError):
self.add_misc(uid)
def hyphenate_if_possible(no_hyphens):
try:
return normalize_isbn(no_hyphens)
except ISBNError:
return no_hyphens
def isbns(self, key, value):
"""ISBN, its medium and an additional comment."""
try:
isbn = normalize_isbn(force_single_element(value['a']))
# See https://github.com/nekobcn/isbnid/issues/2 and
# https://github.com/nekobcn/isbnid/issues/3 for understanding the long
# exception list.
except (KeyError, ISBNError, ISBNRangeError, UnicodeEncodeError):
return {}
b = value.get('b', '').lower()
if 'online' == b:
medium = 'online'
comment = ''
elif 'print' == b:
medium = 'print'
comment = ''
elif 'electronic' in b:
medium = 'online'
comment = 'electronic'