Created
June 30, 2018 16:28
-
-
Save KhasMek/9f013af4904ba935ed1f2c9ef1fcf3b7 to your computer and use it in GitHub Desktop.
quick lookups for organization (and other types tba) sizes.
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 | |
# | |
# Requirements: | |
# - humanfriendly | |
# - pygithub | |
import humanfriendly | |
import sys | |
from github import Github | |
token = '' | |
g = Github(token) | |
def get_org_repos(organization, visibility='public'): | |
repos = [] | |
for repo in g.get_organization(organization).get_repos(visibility): | |
repos.append(repo.full_name) | |
return repos | |
def do_all_org(organization, visibility='public'): | |
repo_sizes = [] | |
for repo in g.get_organization(organization).get_repos(visibility): | |
repo_sizes.append(repo.size) | |
print(" [+] Total number of repos: {}".format(len(repo_sizes))) | |
org_size_bytes = humanfriendly.parse_size(str("{}K".format(sum(repo_sizes)))) | |
print(" [+] Total Size of Organization: {}".format(humanfriendly.format_size(org_size_bytes))) | |
if __name__ == "__main__": | |
if sys.argv[1] == "org": | |
do_all_org(sys.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment