From c87b5344c16274d3dc7af97b144e2bfbf042b2b4 Mon Sep 17 00:00:00 2001 From: Daniel Gnoutcheff Date: Mon, 23 Jan 2017 18:57:12 -0500 Subject: add github-fetch --- github-fetch.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 github-fetch.py diff --git a/github-fetch.py b/github-fetch.py new file mode 100644 index 0000000..07bbf52 --- /dev/null +++ b/github-fetch.py @@ -0,0 +1,26 @@ +# Print git clone commands for each repository created by a given github +# account. + +import requests +import sys + +def pages(starturl): + r = requests.get(starturl) + yield r + while 'next' in r.links: + r = requests.get(r.links['next']['url']) + yield r + +#pgs = list(pages('https://api.github.com/users/cloudfoundry/repos')) +#for page in pgs: +# for repo in page.json(): +# print('git clone {}'.format(repo['clone_url'])) + +def cloneurls(accountname): + starturl = 'https://api.github.com/users/{}/repos'.format(accountname) + for page in pages(starturl): + for repo in page.json(): + yield repo['clone_url'] + +for url in cloneurls(sys.argv[1]): + print('git clone {}'.format(url)) -- cgit v1.2.3