-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.py
More file actions
41 lines (33 loc) · 1.23 KB
/
users.py
File metadata and controls
41 lines (33 loc) · 1.23 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
29
30
31
32
33
34
35
36
37
38
39
40
41
import json
from bs4 import BeautifulSoup
from repos import Repos, repo
from AuthoRequest import AuthoRequest
class Users(dict):
def __init__(self, lastid):
self.lastid = lastid
class user(object):
def __init__(self, userName):
self.userName = userName
self.userJson = self.getUserJson(userName)
self.parseJson()
self.createRepos()
def getUserJson(self, userName):
userURL = 'https://api.github.com/users/' + userName
the_page = AuthoRequest(userURL)
soup = BeautifulSoup(the_page, "html5lib")
reposJson = json.loads(soup.get_text())
return(reposJson)
def parseJson(self):
self.name = self.userJson['name']
self.public_repos = self.userJson['public_repos']
self.hireable = self.userJson['hireable']
def createRepos(self):
self.Repos = Repos()
userURL = 'https://api.github.com/users/' + self.userName + '/repos'
the_page = AuthoRequest(userURL)
soup = BeautifulSoup(the_page, "html5lib")
reposJson = json.loads(soup.get_text())
for i in reposJson:
repoName = i["name"]
self.Repos[repoName] = repo(repoName)
self.Repos[repoName].setRepoJson(i)