summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))