Created
March 24, 2020 07:35
-
-
Save Qkessler/ac23b4b5ac03ca84aa622649056dd731 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