-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
45 lines (37 loc) · 1.35 KB
/
main.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
from github import Github
from config import get_config
class Collector:
def __init__(self, access=[]):
if len(access) == 1:
self.g = Github(access[0])
def get_org(self, org):
o = self.g.get_organization(org)
return o
def get_org_repos(self, org):
o = self.g.get_organization(org)
print("get_org_repos")
repos = [repo.full_name for repo in list(o.get_repos())]
return repos
def get_all_contributors(self, org, repo):
url = org + repo
r = self.g.get_repo(url)
print("get_all_contributors")
contributors = [user.login for user in list(r.get_contributors())]
return contributors
def get_stats_contributors(self, org, repo):
url = org + repo
r = self.g.get_repo(url)
print("get_stats_contributors")
itens = [
{item.author.login: item.raw_data['weeks']}
for item in list(r.get_stats_contributors())
]
return itens
if __name__ == '__main__':
a = get_config()['log']
credentials = [get_config("GITHUB")[a]]
collector = Collector(credentials)
print(collector.get_org_repos("ComputerSocietyUnB"))
print(collector.get_all_contributors("ComputerSocietyUNB/CodingDojo"))
print(collector.get_stats_contributors("ComputerSocietyUNB/CodingDojo"))
print("Done")