Skip to content

Instantly share code, notes, and snippets.

@alt3red
Created May 23, 2018 12:09
Show Gist options
  • Select an option

  • Save alt3red/8bfaf170b5d1f8b1a176b569c21b25c0 to your computer and use it in GitHub Desktop.

Select an option

Save alt3red/8bfaf170b5d1f8b1a176b569c21b25c0 to your computer and use it in GitHub Desktop.
Get user's most popular repos
from collections import namedtuple
Repo = namedtuple('Repo', 'name stars forks')
def get_repo_stats(user, n=5):
repos = []
for repo in user.get_repos():
if repo.fork:
continue
repos.append(Repo(name=repo.name,
stars=repo.stargazers_count,
forks=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