5
5
import re
6
6
import logging
7
7
8
- from agithub .base import API , ConnectionProperties , Client , RequestBody , ResponseBody
8
+ from agithub .base import (
9
+ API , ConnectionProperties , Client , RequestBody , ResponseBody )
9
10
10
11
logger = logging .getLogger (__name__ )
11
12
13
+
12
14
class GitHub (API ):
13
15
"""
14
16
The agnostic GitHub API. It doesn't know, and you don't care.
@@ -92,7 +94,7 @@ def request(self, method, url, bodyData, headers):
92
94
if 'content-type' in headers :
93
95
del headers ['content-type' ]
94
96
95
- #TODO: Context manager
97
+ # TODO: Context manager
96
98
requestBody = RequestBody (bodyData , headers )
97
99
98
100
if self .sleep_on_ratelimit and self .no_ratelimit_remaining ():
@@ -107,12 +109,14 @@ def request(self, method, url, bodyData, headers):
107
109
self .headers = response .getheaders ()
108
110
109
111
conn .close ()
110
- if status == 403 and self .sleep_on_ratelimit and self .no_ratelimit_remaining ():
112
+ if (status == 403 and self .sleep_on_ratelimit and
113
+ self .no_ratelimit_remaining ()):
111
114
self .sleep_until_more_ratelimit ()
112
115
else :
113
116
data = content .processBody ()
114
117
if self .paginate and type (data ) == list :
115
- data .extend (self .get_additional_pages (method , bodyData , headers ))
118
+ data .extend (
119
+ self .get_additional_pages (method , bodyData , headers ))
116
120
return status , data
117
121
118
122
def get_additional_pages (self , method , bodyData , headers ):
@@ -165,9 +169,10 @@ def get_next_link_url(self):
165
169
"""Given a set of HTTP headers find the RFC 5988 Link header field,
166
170
determine if it contains a relation type indicating a next resource and
167
171
if so return the URL of the next resource, otherwise return an empty
168
- string."""
172
+ string.
169
173
170
- # From https://github.com/requests/requests/blob/master/requests/utils.py
174
+ From https://github.com/requests/requests/blob/master/requests/utils.py
175
+ """
171
176
for value in [x [1 ] for x in self .headers if x [0 ].lower () == 'link' ]:
172
177
replace_chars = ' \' "'
173
178
value = value .strip (replace_chars )
0 commit comments