@@ -15,6 +15,8 @@ def __init__(self, count, url, cls, session, params=None, etag=None,
15
15
self .count = count
16
16
#: URL the class used to make it's first GET
17
17
self .url = url
18
+ #: Last URL that was requested
19
+ self .last_url = None
18
20
self ._api = self .url
19
21
#: Class for constructing an item to return
20
22
self .cls = cls
@@ -43,7 +45,7 @@ def _repr(self):
43
45
return '<GitHubIterator [{0}, {1}]>' .format (self .count , self .path )
44
46
45
47
def __iter__ (self ):
46
- url , params , cls = self .url , self .params , self .cls
48
+ self . last_url , params , cls = self .url , self .params , self .cls
47
49
headers = self .headers
48
50
49
51
if 0 < self .count <= 100 and self .count != - 1 :
@@ -52,8 +54,9 @@ def __iter__(self):
52
54
if 'per_page' not in params and self .count == - 1 :
53
55
params ['per_page' ] = 100
54
56
55
- while (self .count == - 1 or self .count > 0 ) and url :
56
- response = self ._get (url , params = params , headers = headers )
57
+ while (self .count == - 1 or self .count > 0 ) and self .last_url :
58
+ response = self ._get (self .last_url , params = params ,
59
+ headers = headers )
57
60
self .last_response = response
58
61
self .last_status = response .status_code
59
62
if params :
@@ -82,7 +85,7 @@ def __iter__(self):
82
85
break
83
86
84
87
rel_next = response .links .get ('next' , {})
85
- url = rel_next .get ('url' , '' )
88
+ self . last_url = rel_next .get ('url' , '' )
86
89
87
90
def __next__ (self ):
88
91
if not hasattr (self , '__i__' ):
0 commit comments