Last active
April 27, 2019 05:02
-
-
Save bnikanjam/0a07a77a56db021a9b949a05ca84d955 to your computer and use it in GitHub Desktop.
Top Github 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
"""Top Repos with Github public API (No Auth)""" | |
from github import Github | |
from collections import namedtuple | |
Repo = namedtuple('Repo', 'name stars forks url') | |
username = 'llSourcell' | |
git_user = Github().get_user(username) | |
def most_popular_repos(gh_user, top=5): | |
"""Return own top repos of input github user.""" | |
repos = [] | |
for repo in gh_user.get_repos(): | |
if repo.fork: | |
continue | |
repos.append(Repo(name=repo.name, | |
stars=repo.stargazers_count, | |
forks=repo.forks_count, | |
url=repo.html_url)) | |
return sorted(repos, key=lambda x: 3 * x.forks + 2 * x.stars, reverse=True)[:top] | |
top_repos = most_popular_repos(git_user) | |
for repo in top_repos: | |
print(f'🍴{repo.forks:<4} ⭐{repo.stars:<4} {repo.name}\n{repo.url}\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment