Created
January 20, 2019 14:19
-
-
Save voodoodror/bf0e1d601d46cba0e73cb812b8e78dee 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
import json | |
import requests | |
gh_token = '<GITHUB_TOKEN>' | |
results = [] | |
params = {'page': 1, 'per_page':100} | |
another_page = True | |
api = 'https://api.github.com/orgs/<ORG>/repos' | |
while another_page: | |
r = requests.get(api, params=params, headers={'Authorization': 'token {}'.format(gh_token)}) | |
json_response = json.loads(r.text) | |
params['page'] += 1 | |
for repository in json_response: | |
results.append(repository) | |
if 'next' in r.links: | |
api = r.links['next']['url'] | |
else: | |
another_page=False | |
repo_names = map(lambda x: x['name'], results) | |
private = map(lambda x: x['private'], results) | |
language = map(lambda x: x['language'], results) | |
description = map(lambda x: x['description'], results) | |
html_url = map(lambda x: x['html_url'], results) | |
repos = [] | |
for x in xrange(1,len(repo_names)): | |
repos.append('{},{},{},{},{}'.format(str(repo_names[x]), | |
str(private[x]), | |
str(language[x]), | |
str(description[x]), | |
str(html_url[x]))) | |
repos.sort() | |
print 'NAME,PRIVATE,LANGAUGE,DESCRIPTION,HTML_URL' | |
for repo in repos: | |
print repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment