Skip to content

Instantly share code, notes, and snippets.

@yshalsager
Created July 4, 2020 19:46
Show Gist options
  • Save yshalsager/28355054f46f9215c6f654a78ff86ec6 to your computer and use it in GitHub Desktop.
Save yshalsager/28355054f46f9215c6f654a78ff86ec6 to your computer and use it in GitHub Desktop.
#!/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