Created
November 12, 2016 18:56
-
-
Save David-Estevez/fc3d5939a23ea951e7f17cd99bafe1cc to your computer and use it in GitHub Desktop.
repostatistics
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
import requests, json | |
import operator | |
from tqdm import tqdm | |
def main(): | |
org = 'asrob-uc3m' | |
url_repos = 'https://api.github.com/orgs/{}/repos' | |
url_repo_contributors = 'https://api.github.com/repos/{}/{}/contributors' | |
contributors = {} | |
resp = requests.get(url=url_repos.format(org)) | |
data = json.loads(resp.text) | |
for repo in tqdm(data): | |
#print(repo) | |
resp = requests.get(url_repo_contributors.format(org, repo['name'])) | |
contrib_data = json.loads(resp.text) | |
for contributor in contrib_data: | |
total_contribs = contributors.get(contributor['login'], 0) | |
total_contribs += int(contributor['contributions']) | |
contributors[contributor['login']] = total_contribs | |
for i, contributor in enumerate(reversed(sorted(contributors.items(), key=operator.itemgetter(1)))): | |
print("{:2.0f}. {} -> {}".format(i, contributor[0], contributor[1])) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment