Created
March 24, 2020 07:39
-
-
Save Qkessler/01be9df209a558d903cb35e5d6daf5a9 to your computer and use it in GitHub Desktop.
Get GH user's most popular repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Repo = namedtuple('Repo', 'name stars forks') | |
from collections import namedtuple | |
def get_repo_stats(user, n=5): | |
repos = [] | |
for repo in user.get_repos(): | |
if repo.fork: | |
continue | |
repos.append(Repo(repo.name, repo.stargazers_count, repo.forks_count)) | |
return sorted(repos, key=lambda x: x.stars, reverse=True)[:n] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment