|
1 |
| -#!/usr/bin/python |
| 1 | +#!/usr/bin/python3 |
2 | 2 | import argparse
|
3 | 3 | import json
|
4 |
| -import urllib2 |
| 4 | +import urllib3 |
5 | 5 | import os
|
6 | 6 | import subprocess
|
7 | 7 | import re
|
|
18 | 18 | args = parser.parse_args()
|
19 | 19 |
|
20 | 20 | os.chdir(args.directory)
|
21 |
| -f = urllib2.urlopen("https://api.github.com/users/%s/repos" % args.user) |
22 |
| -repo_list = json.loads(f.read()) |
| 21 | +http = urllib3.PoolManager() |
| 22 | +f = http.request("GET", "https://api.github.com/users/%s/repos" % args.user) |
| 23 | +repo_list = json.loads(f.data) |
23 | 24 |
|
24 | 25 | for repo in repo_list:
|
25 | 26 | name, url = repo["name"], repo["clone_url"]
|
26 | 27 | if re.search("[^A-z0-9-_]", name):
|
27 |
| - print "Skipping invalid name", name |
| 28 | + print("Skipping invalid name", name) |
28 | 29 | continue
|
29 | 30 | if re.search("[^A-z0-9-_:/.]", url):
|
30 |
| - print "Skipping invalid url", url |
| 31 | + print ("Skipping invalid url", url) |
31 | 32 | continue
|
32 | 33 | if repo["private"]:
|
33 |
| - print "Skipping private repo", name |
| 34 | + print ("Skipping private repo", name) |
34 | 35 | continue
|
35 | 36 | if repo["fork"] and not args.forks:
|
36 |
| - print "Skipping forked repo", name |
| 37 | + print ("Skipping forked repo", name) |
37 | 38 | continue
|
38 | 39 | if not os.path.exists(name):
|
39 |
| - print "New repo", name |
| 40 | + print("New repo", name) |
40 | 41 | subprocess.check_output(["git", "clone", "--mirror", url, name], stderr=subprocess.STDOUT)
|
41 | 42 | os.chdir(name)
|
42 |
| - print "Updating", name |
| 43 | + print("Updating", name) |
43 | 44 | subprocess.check_output(["git", "remote", "update"])
|
44 | 45 | os.chdir("..")
|
0 commit comments