2
2
import py
3
3
import textwrap
4
4
5
- issues_url = "http ://bitbucket.org/ api/1.0/repositories /pytest-dev/pytest/issues"
5
+ issues_url = "https ://api.github.com/repos /pytest-dev/pytest/issues"
6
6
7
7
import requests
8
8
9
+
9
10
def get_issues ():
10
- chunksize = 50
11
- start = 0
12
11
issues = []
12
+ url = issues_url
13
13
while 1 :
14
- post_data = {"accountname" : "pytest-dev" ,
15
- "repo_slug" : "pytest" ,
16
- "start" : start ,
17
- "limit" : chunksize }
18
- print ("getting from" , start )
19
- r = requests .get (issues_url , params = post_data )
14
+ get_data = {"state" : "all" }
15
+ r = requests .get (url , params = get_data )
20
16
data = r .json ()
21
- issues .extend (data ["issues" ])
22
- if start + chunksize >= data ["count" ]:
23
- return issues
24
- start += chunksize
17
+ if r .status_code == 403 :
18
+ # API request limit exceeded
19
+ print (data ['message' ])
20
+ exit (1 )
21
+ issues .extend (data )
25
22
26
- kind2num = "bug enhancement task proposal" .split ()
23
+ # Look for next page
24
+ links = requests .utils .parse_header_links (r .headers ['Link' ])
25
+ another_page = False
26
+ for link in links :
27
+ if link ['rel' ] == 'next' :
28
+ url = link ['url' ]
29
+ another_page = True
30
+ if not another_page :
31
+ return issues
27
32
28
- status2num = "new open resolved duplicate invalid wontfix" .split ()
29
33
30
34
def main (args ):
31
35
cachefile = py .path .local (args .cache )
@@ -35,33 +39,38 @@ def main(args):
35
39
else :
36
40
issues = json .loads (cachefile .read ())
37
41
38
- open_issues = [x for x in issues
39
- if x ["status" ] in ("new" , "open" )]
42
+ open_issues = [x for x in issues if x ["state" ] == "open" ]
40
43
41
- def kind_and_id (x ):
42
- kind = x ["metadata" ]["kind" ]
43
- return kind2num .index (kind ), len (issues )- int (x ["local_id" ])
44
- open_issues .sort (key = kind_and_id )
44
+ open_issues .sort (key = lambda x : x ["number" ])
45
45
report (open_issues )
46
46
47
+
48
+ def _get_kind (issue ):
49
+ labels = [l ['name' ] for l in issue ['labels' ]]
50
+ for key in ('bug' , 'enhancement' , 'proposal' ):
51
+ if key in labels :
52
+ return key
53
+ return 'issue'
54
+
55
+
47
56
def report (issues ):
48
57
for issue in issues :
49
- metadata = issue ["metadata" ]
50
- priority = issue ["priority" ]
51
58
title = issue ["title" ]
52
- content = issue ["content " ]
53
- kind = metadata [ "kind" ]
54
- status = issue ["status " ]
55
- id = issue ["local_id " ]
56
- link = "https://bitbucket.org /pytest-dev/pytest/issue /%s/" % id
59
+ body = issue ["body " ]
60
+ kind = _get_kind ( issue )
61
+ status = issue ["state " ]
62
+ number = issue ["number " ]
63
+ link = "https://github.com /pytest-dev/pytest/issues /%s/" % number
57
64
print ("----" )
58
65
print (status , kind , link )
59
66
print (title )
60
67
#print()
61
- #lines = content .split("\n")
68
+ #lines = body .split("\n")
62
69
#print ("\n".join(lines[:3]))
63
- #if len(lines) > 3 or len(content ) > 240:
70
+ #if len(lines) > 3 or len(body ) > 240:
64
71
# print ("...")
72
+ print ("\n \n Found %s open issues" % len (issues ))
73
+
65
74
66
75
if __name__ == "__main__" :
67
76
import argparse
@@ -72,3 +81,4 @@ def report(issues):
72
81
help = "cache file" )
73
82
args = parser .parse_args ()
74
83
main (args )
84
+
0 commit comments