-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrepo.py
48 lines (37 loc) · 1.42 KB
/
repo.py
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
42
43
44
45
46
47
48
import json
import requests
from helpme import save_json, extract_data, group_with_same_key
class Repo():
def __init__(self, username, project_name):
self.username = username
self.project_name = project_name
def get_repo_stats(self):
RepoURL = 'https://api.github.com/repos/{}/{}'.format(
self.username, self.project_name)
RepoDataFromGithub = requests.get(RepoURL).json()
DataNeeded = [
'name',
'html_url',
'description',
'forks',
'open_issues',
'language',
'git_url',
]
self.RepoData = extract_data(DataNeeded, RepoDataFromGithub)
save_json('output_of_Repo', self.RepoData)
return json.dumps(self.RepoData, indent=True)
def get_sha_values(self):
CommitURL = 'https://api.github.com/repos/{}/{}/commits'.format(
self.username, self.project_name)
CommitListFromGithub = requests.get(CommitURL).json()
# CommitListExtracted = group_with_same_key(CommitListFromGithub,'sha')
CommitIDList = []
for i in range(len(CommitListFromGithub)):
CommitIDList.append(CommitListFromGithub[i]['name'])
return CommitIDList
# save_json('CommitListFromGithub', CommitListFromGithub)
repo = Repo('avikantsrivastava', '100-days-of-ML-Code')
data = repo.get_repo_stats()
repo.get_sha_values()
# print(data)