From 5ec28e7657af82c3260fcf67db4e7b2ea4ba6a36 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 10 Sep 2018 18:06:12 -0700 Subject: fix python import of ORCIDs ending 'X' --- python/fatcat/importer_common.py | 2 +- python/tests/files/0000-0003-3953-765X.json | 1 + python/tests/importer.py | 1 + python/tests/orcid.py | 6 ++++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 python/tests/files/0000-0003-3953-765X.json (limited to 'python') diff --git a/python/fatcat/importer_common.py b/python/fatcat/importer_common.py index 0b02d175..74a57ac1 100644 --- a/python/fatcat/importer_common.py +++ b/python/fatcat/importer_common.py @@ -23,7 +23,7 @@ class FatcatImporter: self._orcid_id_map = dict() self._doi_id_map = dict() self._issn_issnl_map = None - self._orcid_regex = re.compile("^\\d{4}-\\d{4}-\\d{4}-\\d{4}$") + self._orcid_regex = re.compile("^\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]$") if issn_map_file: self.read_issn_map_file(issn_map_file) diff --git a/python/tests/files/0000-0003-3953-765X.json b/python/tests/files/0000-0003-3953-765X.json new file mode 100644 index 00000000..9699d1bf --- /dev/null +++ b/python/tests/files/0000-0003-3953-765X.json @@ -0,0 +1 @@ +{"orcid-identifier":{"uri":"http://orcid.org/0000-0003-3953-765X","path":"0000-0003-3953-765X","host":"orcid.org"},"preferences":{"locale":"en"},"history":{"creation-method":"Member-referred","completion-date":null,"submission-date":{"value":1407501041999},"last-modified-date":{"value":1465949566770},"claimed":true,"source":null,"deactivation-date":null,"verified-email":true,"verified-primary-email":true},"person":{"last-modified-date":null,"name":{"created-date":{"value":1460755375159},"last-modified-date":{"value":1460755375159},"given-names":{"value":"Man-Hui"},"family-name":{"value":"Li"},"credit-name":null,"source":null,"visibility":"public","path":"0000-0003-3953-765X"},"other-names":{"last-modified-date":null,"other-name":null,"path":"/0000-0003-3953-765X/other-names"},"biography":{"created-date":{"value":1460755375161},"last-modified-date":{"value":1460755375161},"content":null,"visibility":"public","path":"/0000-0003-3953-765X/biography"},"researcher-urls":{"last-modified-date":null,"researcher-url":null,"path":"/0000-0003-3953-765X/researcher-urls"},"emails":{"last-modified-date":null,"email":null,"path":"/0000-0003-3953-765X/email"},"addresses":{"last-modified-date":null,"address":null,"path":"/0000-0003-3953-765X/address"},"keywords":{"last-modified-date":null,"keyword":null,"path":"/0000-0003-3953-765X/keywords"},"external-identifiers":{"last-modified-date":null,"external-identifier":null,"path":"/0000-0003-3953-765X/external-identifiers"},"path":"/0000-0003-3953-765X/person"},"activities-summary":{"last-modified-date":null,"educations":{"last-modified-date":null,"education-summary":null,"path":"/0000-0003-3953-765X/educations"},"employments":{"last-modified-date":null,"employment-summary":null,"path":"/0000-0003-3953-765X/employments"},"fundings":{"last-modified-date":null,"group":null,"path":"/0000-0003-3953-765X/fundings"},"peer-reviews":{"last-modified-date":null,"group":null,"path":"/0000-0003-3953-765X/peer-reviews"},"works":{"last-modified-date":null,"group":null,"path":"/0000-0003-3953-765X/works"},"path":"/0000-0003-3953-765X/activities"},"path":"/0000-0003-3953-765X"} diff --git a/python/tests/importer.py b/python/tests/importer.py index 4d49e794..22af37ed 100644 --- a/python/tests/importer.py +++ b/python/tests/importer.py @@ -29,6 +29,7 @@ def test_identifiers(): assert fi.is_doi("10.1234_56789") == False assert fi.is_orcid("0000-0003-3118-6591") == True + assert fi.is_orcid("0000-0003-3953-765X") == True assert fi.is_orcid("0000-00x3-3118-659") == False assert fi.is_orcid("0000-00033118-659") == False assert fi.is_orcid("0000-0003-3118-659.") == False diff --git a/python/tests/orcid.py b/python/tests/orcid.py index e07583ac..ae3d0d0b 100644 --- a/python/tests/orcid.py +++ b/python/tests/orcid.py @@ -21,6 +21,12 @@ def test_orcid_importer(orcid_importer): with open('tests/files/0000-0001-8254-7103.json', 'r') as f: orcid_importer.process_source(f) +def test_orcid_importer_x(orcid_importer): + with open('tests/files/0000-0003-3953-765X.json', 'r') as f: + orcid_importer.process_source(f) + c = orcid_importer.api.lookup_creator(orcid="0000-0003-3953-765X") + assert c is not None + def test_orcid_dict_parse(orcid_importer): with open('tests/files/0000-0001-8254-7103.json', 'r') as f: raw = json.loads(f.readline()) -- cgit v1.2.3