Skip to content

Commit 52cea88

Browse files
committed
added new script, updated readme, updated todo:
1 parent 14147e3 commit 52cea88

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

TODO.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
1. Add Travis
33
1. Add support for Python 2.7, 3.5, and 3.6
44
1. Organize docs and folder structure better
5+
1. Add all scripts to single CLI for easy running, testing, and searching
6+
1. Add License

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@
3232
1. **30_fullcontact.py**: Call the [FullcContact](https://www.fullcontact.com/developer/) API
3333
1. **31_youtube_sentiment.py**: Calculate sentiment score from the comments of a Youtube video
3434
1. **32_stock_scraper.py**: Get stock prices
35+
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`

scripts/34_git_all_repos.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import sys
2+
import os
3+
import requests
4+
5+
6+
def get_total_repos(group, name):
7+
repo_urls = []
8+
page = 1
9+
while True:
10+
url = 'https://api.github.com/{0}/{1}/repos?per_page=100&page={2}'
11+
r = requests.get(url.format(group, name, page))
12+
if r.status_code == 200:
13+
rdata = r.json()
14+
for repo in rdata:
15+
repo_urls.append(repo['clone_url'])
16+
if (len(rdata) >= 100):
17+
page += 1
18+
else:
19+
print('Found {0} repos.'.format(len(repo_urls)))
20+
break
21+
else:
22+
print(r)
23+
return False
24+
return repo_urls
25+
26+
27+
def clone_repos(all_repos):
28+
count = 1
29+
print('Cloning...')
30+
for repo in all_repos:
31+
os.system('Git clone ' + repo)
32+
print('Completed repo #{0} of {1}'.format(count, len(all_repos)))
33+
count += 1
34+
35+
if __name__ == '__main__':
36+
if len(sys.argv) > 2:
37+
total = get_total_repos(sys.argv[1], sys.argv[2])
38+
if total:
39+
clone_repos(total)
40+
41+
else:
42+
print('Usage: python USERS_OR_ORG GITHUB_USER_OR_ORG-NAME')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy