- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.py
More file actions
Latest commit
29 lines (22 loc) · 1.03 KB
/
Copy pathgithub.py
File metadata and controls
29 lines (22 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
__author__='afreisth'
importurllib2
importjson
# Class using github api put together as an example for mock library evaluation
classGitHub(object):
def__init__(self, username):
self.username=username
defget_id(self):
result=urllib2.urlopen('https://api.github.com/users/{0}'.format(self.username))
returnjson.load(result).get('id', None)
defget_number_public_repos(self):
result=urllib2.urlopen('https://api.github.com/users/{0}'.format(self.username))
returnjson.load(result).get('public_repos', None)
defget_public_repo_uris(self):
result=urllib2.urlopen('https://api.github.com/users/{0}/repos'.format(self.username))
repos=json.load(result)
return [repo['html_url'] forrepoinreposifnotrepo['private']]
defget_all_details(self):
id=self.get_id()
number_public_repos=self.get_number_public_repos()
public_repo_uris=self.get_public_repo_uris()
returnid, number_public_repos, public_repo_uris