summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2017-01-23 18:57:12 -0500
committerDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2017-01-23 18:57:12 -0500
commitc87b5344c16274d3dc7af97b144e2bfbf042b2b4 (patch)
tree7a5cc97b87fe885774f04f3794eea9659866385d
parentd7c84268a26a4391af55a3533422367b02737435 (diff)
add github-fetch
-rw-r--r--github-fetch.py26
1 files changed, 26 insertions, 0 deletions
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))