Skip to content

Commit

Permalink
Fix: Better handling non str identifiers
Browse files Browse the repository at this point in the history
This is to fix related identifiers like ISBNs where they are integers.
Convert all to string but only try to strip from already strings
  • Loading branch information
richardhallett committed Apr 20, 2020
1 parent 8115d0e commit 41c362d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions viringo/services/datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ def build_metadata(data):

def strip_uri_prefix(identifier):
"""Strip common prefixes because OAI doesn't work with those kind of ID's"""
if identifier:
if identifier and isinstance(identifier, str):
if identifier.startswith("https://doi.org/"):
_, identifier = identifier.split("https://doi.org/", 1)
else:
identifier = ''
identifier = str(identifier)
return identifier

def get_metadata(doi):
Expand Down

0 comments on commit 41c362d

Please sign in to comment.