-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreatePointsReport.py
More file actions
executable file
·69 lines (56 loc) · 2.41 KB
/
createPointsReport.py
File metadata and controls
executable file
·69 lines (56 loc) · 2.41 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
# createPointsReport.py iterates through every comment in every issue in every repo in the
# specified organization, and generates a .csv file containing the points and users associated
# with each issue
import getpass
import sys
import argparse
# In the main directory of the repo where you are developing with PyGithub,
# type:
# git submodule add git://github.com/jacquev6/PyGithub.git PyGithub
# git submodule init
# git submodule update
#
# That will populate a PyGithub subdirectory with a clone of PyGithub
# Then, to add it to your Python path, you can do:
sys.path.append("./PyGithub");
from github import Github
from github import GithubException
parser = argparse.ArgumentParser(description='List all repos for an org')
parser.add_argument('orgName',help='github Organization name')
args = parser.parse_args()
username = raw_input("Github Username:")
pw = getpass.getpass()
g = Github(username, pw, user_agent="PyGithub")
print("All repos for organization: ",args.orgName)
org = g.get_organization(args.orgName)
## TODO: Add some error checking code here to see whether
## the lookup was successful. Do we try/except or check the return value?
repos = org.get_repos()
# Iterate through all the comments in all the issues in all the repos
for repo in repos:
issues = repo.get_issues()
issue_report = {"repository" : repo.full_name,
"estimated" : 0,
"requested" : 0,
"assigned" : 0,
"assignee_id" : 0,
"esimatee_id" : 0,
"requestee_id" : 0}
for issue in issues:
issue_report["issue"] = issue.id
comments = issue.get_comments()
for comment in comments:
comment_text = comment.body
words = comment_text.split(" ")
for i in range(0, len(words) - 1):
if words[i] == "~estimated":
issue_report["estimated"] = int(words[i + 1])
issue_report["estimatee_id"] = comment.user.id
elif words[i] == "~assigned":
issue_report["assigned"] = int(words[i + 1])
issue_report["assignee_id"] = comment.user.id
elif words[i] == "~requested":
issue_report["requested"] = int(words[i + 1])
issue_report["requestee_id"] = comment.user.id
print issue_report