added new script, updated readme, updated todo:

This commit is contained in:
Michael Herman 2016-12-17 09:28:23 -07:00
parent 14147e3dd0
commit 52cea88b4f
3 changed files with 45 additions and 0 deletions

View File

@ -2,3 +2,5 @@
1. Add Travis
1. Add support for Python 2.7, 3.5, and 3.6
1. Organize docs and folder structure better
1. Add all scripts to single CLI for easy running, testing, and searching
1. Add License

View File

@ -32,3 +32,4 @@
1. **30_fullcontact.py**: Call the [FullcContact](https://www.fullcontact.com/developer/) API
1. **31_youtube_sentiment.py**: Calculate sentiment score from the comments of a Youtube video
1. **32_stock_scraper.py**: Get stock prices
1. **34_git_all_repos.py**: Clone all repositories from a public user or organization on Github. Usage: `python git_all_repos.py users USER_NAME` or `python git_all_repos.py orgs ORG_NAME`

View File

@ -0,0 +1,42 @@
import sys
import os
import requests
def get_total_repos(group, name):
repo_urls = []
page = 1
while True:
url = 'https://api.github.com/{0}/{1}/repos?per_page=100&page={2}'
r = requests.get(url.format(group, name, page))
if r.status_code == 200:
rdata = r.json()
for repo in rdata:
repo_urls.append(repo['clone_url'])
if (len(rdata) >= 100):
page += 1
else:
print('Found {0} repos.'.format(len(repo_urls)))
break
else:
print(r)
return False
return repo_urls
def clone_repos(all_repos):
count = 1
print('Cloning...')
for repo in all_repos:
os.system('Git clone ' + repo)
print('Completed repo #{0} of {1}'.format(count, len(all_repos)))
count += 1
if __name__ == '__main__':
if len(sys.argv) > 2:
total = get_total_repos(sys.argv[1], sys.argv[2])
if total:
clone_repos(total)
else:
print('Usage: python USERS_OR_ORG GITHUB_USER_OR_ORG-NAME')