Skip to content

Commit

Permalink
Updating to fix bug that we do not allow repos to end in .git (#42)
Browse files Browse the repository at this point in the history
* updating to fix bug that we do not allow repos to end in .git
* making sure that zenodo update also updates orcid identifiers

Signed-off-by: vsoch <vsochat@stanford.edu>
  • Loading branch information
vsoch committed Jul 30, 2020
1 parent 7718482 commit 1473a0f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
8 changes: 6 additions & 2 deletions .tributors
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
"yarikoptic": {
"name": "Yaroslav Halchenko",
"blog": "www.onerussian.com",
"email": "debian@onerussian.com",
"bio": "Cheers!",
"orcid": "0000-0003-3456-2493",
"affiliation": "Dartmouth College"
},
"vsoch": {
"name": "Vanessasaurus",
"blog": "https://vsoch.github.io"
"blog": "https://vsoch.github.io",
"bio": "I'm the Vanessasaurus!"
},
"pgrimaud": {
"name": "Pierre Grimaud",
"blog": "https://github.com/pgrimaud"
"blog": "https://github.com/pgrimaud",
"bio": "Technical Manager @bigyouth / IT Teacher / Retired gladiator"
}
}
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)
- should allow for repository names with .git extension (0.0.15)
- adding support to do updates `--from` (between) resources (0.0.14)
- adding github to update-lookup, not doing by default (0.0.13)
- support for updating .tributors from a lookup (0.0.12)
Expand Down
2 changes: 1 addition & 1 deletion tributors/main/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,4 @@ def get_github_repository(repo):
if not match:
sys.exit("Malformed repository address %s" % repo)
owner, repo = match.groups()
return "%s/%s" % (owner, repo)
return "%s/%s" % (owner, re.sub(".git$", "", repo, 1))
29 changes: 25 additions & 4 deletions tributors/main/parsers/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from tributors.utils.file import write_json
from .base import ParserBase
from tributors.main.orcid import get_orcid

bot = logging.getLogger(" zenodo")

Expand Down Expand Up @@ -108,9 +109,26 @@ def update_from_orcids(self, orcids):
self.data["creators"].append(entry)
return self.data["creators"]

def update_orcids(self):
"""Zenodo is a special case that has emails and real usernames, so we
can parse through the existing file and look for orcid identifiers
"""
creators = []
for user in self.data.get("creators", []):
name = user.get("name")
email = user.get("email")
if email or name and self.orcid_token is not None:
orcid = get_orcid(email=email, token=self.orcid_token, name=name)
if orcid:
user["orcid"] = orcid
creators.append(user)
self.data["creators"] = creators

def update_from_emails(self, emails):
"""Given a list of emails, update the contributor file from it
"""Given a list of emails, update the contributor file from it. We also
look for new orcid ids for emails that don't have them.
"""
# First loop through emails in the cache
lookup = {x["email"]: x for _, x in self.cache.items() if "email" in x}
for email in emails:
if email in self.email_lookup:
Expand All @@ -124,7 +142,9 @@ def update_from_emails(self, emails):
return self.data["creators"]

def update_from_logins(self, logins):
"""Given a list of logins, update the contributor file from it
"""Given a list of logins, update the zenodo.json from it. We only
do this on init when we haven't added /updated logins with
people's actual names.
"""
# GitHub contributors are the source of truth
for login in logins:
Expand Down Expand Up @@ -169,8 +189,9 @@ def update(self, thresh=1, from_resources=None, save=True):

self.update_cache()

# Update zenodo file from GitHub logins (default) or other
self.update_from_logins(from_resources.get("login", []))
# Here we can only reasonable update from orcids (not logins)
self.update_orcids()
self.update_from_emails(from_resources.get("email", []))
self.update_from_orcids(from_resources.get("orcid", []))
self.update_from_names(from_resources.get("names", []))
if save:
Expand Down
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.14"
__version__ = "0.0.15"
AUTHOR = "Vanessa Sochat"
AUTHOR_EMAIL = "vsochat@stanford.edu"
NAME = "tributors"
Expand Down

0 comments on commit 1473a0f

Please sign in to comment.