Created
July 4, 2020 19:46
-
-
Save yshalsager/28355054f46f9215c6f654a78ff86ec6 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
from humanize import naturalsize | |
from requests import get | |
org = "" | |
org_size = [] | |
repo_count = 0 | |
response = get(f"https://api.github.com/orgs/{org}/repos") | |
while True: | |
repos = response.json() | |
for repo in repos: | |
org_size.append(int(repo["size"])) | |
repo_count += 1 | |
try: | |
response = get(response.links["next"]["url"]) | |
except KeyError: | |
break | |
total = sum(org_size * 1024) | |
print(f'{org} has {repo_count} repositories which sum up to {naturalsize(total)}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment