Skip to content

Instantly share code, notes, and snippets.

@Qkessler
Created March 24, 2020 07:39
Show Gist options
  • Save Qkessler/01be9df209a558d903cb35e5d6daf5a9 to your computer and use it in GitHub Desktop.
Save Qkessler/01be9df209a558d903cb35e5d6daf5a9 to your computer and use it in GitHub Desktop.
Get GH user's most popular repos
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