Skip to content

Commit

Permalink
changing order of name to check (#45)
Browse files Browse the repository at this point in the history
* changing order of name to check
* remove ipython import
* need to check both orders
* better way to specify delim

Signed-off-by: vsoch <vsochat@stanford.edu>
  • Loading branch information
vsoch committed Jul 30, 2020
1 parent 50117d2 commit e532d4c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
The versions coincide with releases on pip.

## [0.0.x](https://github.com/con/tributors/tree/master) (0.0.x)
- searching for last, first and reverse for orcid lookup (0.0.18)
- unicode characters allowed, and dont update users with orcids (0.0.17)
- should allow for repository names with .git extension (0.0.15)
- adding support to do updates `--from` (between) resources (0.0.14)
Expand Down
25 changes: 23 additions & 2 deletions tributors/main/orcid.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,33 @@ def get_orcid(email, token, name=None):

# Attempt # 2 will use the first and last name
if name is not None and not orcid_id:
parts = name.split(" ")
first, last = parts[0], " ".join(parts[1:])

# If no comma, likely a space delimiter
delim = "," if "," in name else " "
cleaner = "," if delim == " " else " "

parts = name.split(delim)
last, first = parts[0].strip(cleaner), " ".join(parts[1:]).strip(cleaner)
url = (
"https://pub.orcid.org/v3.0/search/?q=given-names:%s+AND+family-name:%s"
% (first, last)
)
orcid_id = record_search(url, token, name)

# Attempt # 3 will try removing the middle name
if " " in first:
url = (
"https://pub.orcid.org/v3.0/search/?q=given-names:%s+AND+family-name:%s"
% (first.split(" ")[0].strip(), last)
)
orcid_id = record_search(url, token, name)

# Attempt # 4 will reverse (some orcid entries are last, first, others the opposite
if orcid_id is None:
url = (
"https://pub.orcid.org/v3.0/search/?q=given-names:%s+AND+family-name:%s"
% (last, first)
)
orcid_id = record_search(url, token, name)

return orcid_id
2 changes: 1 addition & 1 deletion tributors/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

__version__ = "0.0.17"
__version__ = "0.0.18"
AUTHOR = "Vanessa Sochat"
AUTHOR_EMAIL = "vsochat@stanford.edu"
NAME = "tributors"
Expand Down

0 comments on commit e532d4c

Please sign in to comment.