Skip to content

Instantly share code, notes, and snippets.

@Qkessler
Created March 24, 2020 07:35
Show Gist options
  • Save Qkessler/85557f6d25370861d205d33068757fd3 to your computer and use it in GitHub Desktop.
Save Qkessler/85557f6d25370861d205d33068757fd3 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