-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (40 loc) · 1.56 KB
/
Copy pathmain.py
File metadata and controls
49 lines (40 loc) · 1.56 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
42
43
44
45
46
47
48
49
#!/usr/bin/env python
import yaml
import csv
from bl import all_pull_requests, all_comments
if __name__ == '__main__':
with open("config.yaml", "r") as stream:
try:
configs = yaml.safe_load(stream)
print("=====> your configuration: \n {}".format(configs))
user_token = configs['user-token']
user_id = configs['user-id']
repos = configs['githubs']
created_at = configs['created-at']
is_export_csv = configs['csv']
all_prs = []
pr_comments = {}
print("=====> your pull requests:")
for repo in repos:
prs = all_pull_requests(
user_token, user_id, repos=repo, created_at=created_at)
all_prs += prs
print(all_prs)
print("=====> your comments:")
for pr in all_prs:
comments = all_comments(
user_token, pull_request=pr)
pr_comments[pr.html_url] = comments
print(pr_comments)
if is_export_csv == True:
print("======> dump report to out.csv")
with open('./out.csv', 'w') as f:
writer = csv.writer(f)
writer.writerow(['Name', 'comments'])
for key, values in pr_comments.items():
writer.writerow(
[key, len(pr_comments[key])])
except yaml.YAMLError as exc:
print(exc)
except Exception as exc:
print(exc)