49
49
50
50
try :
51
51
import requests
52
- _PY_REQUESTS_INSTALLED = True
52
+ _REQUESTS_INSTALLED = True
53
53
except ImportError :
54
- _PY_REQUESTS_INSTALLED = False
54
+ _REQUESTS_INSTALLED = False
55
55
56
56
57
57
if compat .PY3 :
@@ -99,11 +99,6 @@ def __next__(self):
99
99
BaseIterator .next = lambda self : self .__next__ ()
100
100
101
101
102
- def is_requests_pkg_avail ():
103
- """Checks if 'python-requests' package is already installed."""
104
- return _PY_REQUESTS_INSTALLED
105
-
106
-
107
102
def _is_url (url ):
108
103
"""Check to see if a URL has a valid protocol.
109
104
@@ -228,9 +223,9 @@ def fetch_url(url, http_params=None, skip_requests=False):
228
223
229
224
http_params : dict or requests.Session(), default None
230
225
A python dict containing:
231
- 'auth': tuple (str, str) eg (unae, pwd )
226
+ 'auth': tuple (str, str) eg (username, password )
232
227
'auth': Any other auth object accepted by requests
233
- 'verify': boolean, Default True
228
+ 'verify': boolean, default True
234
229
If False, allow self signed and invalid SSL cert for https
235
230
or
236
231
A python requests.Session object if http(s) path to enable basic auth
@@ -249,14 +244,14 @@ def fetch_url(url, http_params=None, skip_requests=False):
249
244
if not http_params :
250
245
skip_requests = True
251
246
if (not skip_requests ) and \
252
- is_requests_pkg_avail () and \
247
+ _REQUESTS_INSTALLED and \
253
248
_is_handled_by_requests (url ):
254
249
s = gen_session (http_params )
255
250
resp = s .get (url )
256
251
resp .raise_for_status ()
257
252
content_bytes = resp .content
258
253
else :
259
- if http_params and (skip_requests or not is_requests_pkg_avail () ):
254
+ if http_params and (skip_requests or not _REQUESTS_INSTALLED ):
260
255
msg = 'To utilize http_params, python-requests library is ' + \
261
256
'required but not detected'
262
257
raise ValueError (msg )
@@ -285,7 +280,7 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
285
280
A python dict containing:
286
281
'auth': tuple (str, str) eg (unae, pwd)
287
282
'auth': Any other auth object accepted by requests
288
- 'verify': boolean, Default True
283
+ 'verify': boolean, default True
289
284
If False, allow self signed and invalid SSL cert for https
290
285
or
291
286
A python requests.Session object if http(s) path to enable basic auth
0 commit comments