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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# vim: set expandtab ts=4 sw=4 filetype=python:
"""
This will likely be rewritten into something with classes.
"""
import json
import logging
import subprocess
def setup_logging():
log = logging.getLogger('pygithubissues')
h = logging.StreamHandler()
f = logging.Formatter("%(levelname)s %(asctime)s %(message)s")
h.setFormatter(f)
log.addHandler(h)
return log
log = setup_logging()
def list_issues_for_repo(username, password, repo_owner, repo):
"""
Does this::
curl -u "username:password" \\
https://api.github.com/repos/repo_owner/repo/issues
"""
auth_option = '%s:%s' % (username, password)
url = ('https://api.github.com/repos/%s/%s/issues'
% (repo_owner, repo))
args = ['curl', '-u', auth_option, url]
p = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
results = p.communicate()
return json.loads(results[0])
def get_a_single_issue(username, password, repo_owner, repo, issue_id):
"""
Does this::
curl -u "username:password" \\
https://api.github.com/repos/:repo_owner/:repo/issues/:issue_id
"""
auth_option = '%s:%s' % (username, password)
url = ('https://api.github.com/repos/%s/%s/issues/%s'
% (repo_owner, repo, issue_id))
args = ['curl', '-u', auth_option, url]
p = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
results = p.communicate()
return json.loads(results[0])
def list_milestones_for_repo(username, password, repo_owner, repo):
"""
Does this::
curl -u "{username}:{password}" \\
https://api.github.com/repos/{repo_owner}/{repo}/milestones
"""
auth_option = '%s:%s' % (username, password)
url = ('https://api.github.com/repos/%s/%s/milestones'
% (repo_owner, repo))
args = ['curl', '-u', auth_option, url]
p = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
results = p.communicate()
return json.loads(results[0])
def list_issues_in_milestone(username, password, repo_owner, repo,
milestone_number):
"""
Does this::
curl -u "username:password" \\
https://api.github.com/repos/repo_owner/repo/issues \\
?milestone={milestone_number}
"""
auth_option = '%s:%s' % (username, password)
url = ('https://api.github.com/repos/%s/%s/issues?milestone=%s'
% (repo_owner, repo, milestone_number))
args = ['curl', '-u', auth_option, url]
p = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
results = p.communicate()
return json.loads(results[0])
|