Last active
January 11, 2019 10:26
-
-
Save minrk/e5073438d944f7c16788afe064246fa8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
""" | |
Script to get watchers/stars/forks for all repos on a github organization | |
Set GITHUB_API_TOKEN environment variable if you are hitting the API rate limit | |
Requires pygithub and Python 3.6: | |
pip install pygithub | |
Usage: | |
python org-activity.py <org-name> | |
e.g. | |
python org-activity.py binder-examples | |
LICENSE: CC-0 or Public Domain | |
""" | |
import os | |
import sys | |
# pip install pygithub | |
from github import Github as GitHub # fix case! | |
def main(org_name): | |
gh = GitHub() | |
if 'GITHUB_API_TOKEN' in os.environ: | |
gh = GitHub(os.environ['GITHUB_API_TOKEN']) | |
else: | |
gh = GitHub() | |
org = gh.get_organization(org_name) | |
totals = { | |
'watchers': 0, | |
'stars': 0, | |
'forks': 0, | |
} | |
print(f"{'repo':40} {'watch'} {'stars'} {'forks'}") | |
for repo in org.get_repos(): | |
print(f"{repo.full_name:40}" | |
f" {repo.watchers_count:5}" | |
f" {repo.stargazers_count:5}" | |
f" {repo.forks_count:5}" | |
) | |
totals['watchers'] += repo.watchers_count | |
totals['stars'] += repo.stargazers_count | |
totals['forks'] += repo.forks_count | |
print("\nTotals:") | |
for key, value in totals.items(): | |
print(f"{key:8}: {value:4}") | |
if __name__ == '__main__': | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@minrk
Report for binder-examples as of now (Dec 8, 16:29 CET)
That's
watchers : +9
stars : +9
forks : +11
since Nov 29 (blog launch on Nov 30)
And jupyterhub (Dec 8, 16:30 CET)
That's
watchers: +97
stars : +97
forks : +16
since Nov 29 (blog launch on Nov 30)
❗ also @minrk, this is the first time I've known how to run a script like this. Thank's for the push! 😄