diff options
-rw-r--r-- | fuzzycat/verify.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/fuzzycat/verify.py b/fuzzycat/verify.py index 43f011e..50f24c8 100644 --- a/fuzzycat/verify.py +++ b/fuzzycat/verify.py @@ -205,20 +205,19 @@ def compare(a, b): a_doi_rel = get_datacite_related_doi(a) b_doi_rel = get_datacite_related_doi(b) - if glom(b, "ext_ids.doi") in a_doi_rel or glom(a, "ext_ids.doi") in b_doi_rel: - return (Status.STRONG, OK.DATACITE_RELATED_ID) - - arxiv_id_a = a.get("ext_ids", {}).get("arxiv") - arxiv_id_b = b.get("ext_ids", {}).get("arxiv") - if arxiv_id_a and arxiv_id_b: try: - id_a, version_a = arxiv_id_a.split("v") - id_b, version_b = arxiv_id_b.split("v") - if id_a == id_b: - return (Status.STRONG, OK.ARXIV_VERSION) - except ValueError as err: - # TODO: solv-int/9606010v1 - print("[arxiv] unexpected ids {} {}".format(arxiv_id_a, arxiv_id_b), file=sys.stderr) + if glom(b, "ext_ids.doi") in a_doi_rel or glom(a, "ext_ids.doi") in b_doi_rel: + return (Status.STRONG, OK.DATACITE_RELATED_ID) + except PathAccessError: + pass + + try: + id_a = re.match(r"(.*)v[0-9]{1,}$", glom(a, "ext_ids.arxiv")).group(1) + id_b = re.match(r"(.*)v[0-9]{1,}$", glom(b, "ext_ids.arxiv")).group(1) + if id_a == id_b: + return (Status.STRONG, OK.ARXIV_VERSION) + except (AttributeError, ValueError, PathAccessError) as exc: + pass if a.get("release_type") and b.get( "release_type") and a.get("release_type") != b.get("release_type"): |