daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import namedtuple
  2.  
  3.     Repo = namedtuple('Repo', 'name stars forks')
  4.  
  5.  
  6.     def get_repo_stats(user, n=5):
  7.         """Takes a Github user object and returns the top n most popular repos by star count,
  8.            skips forks."""
  9.         repos = []
  10.         for repo in user.get_repos():
  11.             if repo.fork:
  12.                 continue
  13.  
  14.             repos.append(Repo(name=repo.name,
  15.                               stars=repo.stargazers_count,
  16.                               forks=repo.forks_count))
  17.  
  18.         return sorted(repos, key=lambda x: x.stars, reverse=True)[:n]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top