@@ -191,29 +191,29 @@ def _is_handled_by_requests(o):
191
191
return _is_url (o ) and parse_url (o ).scheme in ['http' , 'https' ]
192
192
193
193
194
- def gen_session (url_params ):
194
+ def gen_session (http_params ):
195
195
"""
196
- Generate python-requests session from url_params dict
196
+ Generate python-requests session from http_params dict
197
197
"""
198
198
s = None
199
- if url_params and type (url_params ) is requests .sessions .Session :
200
- s = url_params
199
+ if http_params and type (http_params ) is requests .sessions .Session :
200
+ s = http_params
201
201
else :
202
202
s = requests .Session ()
203
203
s .stream = True
204
204
# Setting accept-encoding to None for backwards compatibility with
205
205
# urlopen. ideally we want to allow gzip download
206
206
# urlopen doesnt decompress automatically, requests does.
207
207
s .headers .update ({'Accept-Encoding' : None })
208
- if url_params and type (url_params ) is dict :
209
- if url_params .get ('auth' , None ) and not s .auth :
210
- s .auth = url_params .get ('auth' )
211
- if url_params .get ('verify' , True ) is False and s .verify is not False :
212
- s .verify = url_params .get ('verify' )
208
+ if http_params and type (http_params ) is dict :
209
+ if http_params .get ('auth' , None ) and not s .auth :
210
+ s .auth = http_params .get ('auth' )
211
+ if http_params .get ('verify' , True ) is False and s .verify is not False :
212
+ s .verify = http_params .get ('verify' )
213
213
return s
214
214
215
215
216
- def fetch_url (url , url_params = None , skip_requests = False ):
216
+ def fetch_url (url , http_params = None , skip_requests = False ):
217
217
"""
218
218
If url is url, first try python-requests else try urllib.
219
219
Note if requests library is used, auto gunzip is
@@ -226,7 +226,7 @@ def fetch_url(url, url_params=None, skip_requests=False):
226
226
'http://cnn.com'
227
227
'file:///home/sky/aaa.csv'
228
228
229
- url_params : dict or requests.Session(), default None
229
+ http_params : dict or requests.Session(), default None
230
230
A python dict containing:
231
231
'auth': tuple (str, str) eg (unae, pwd)
232
232
'auth': Any other auth object accepted by requests
@@ -244,20 +244,20 @@ def fetch_url(url, url_params=None, skip_requests=False):
244
244
.. versionadded:: 0.21.0
245
245
Raises
246
246
------
247
- ValueError if url_params specified without installed python-requests pkg
247
+ ValueError if http_params specified without installed python-requests pkg
248
248
"""
249
- if not url_params :
249
+ if not http_params :
250
250
skip_requests = True
251
251
if (not skip_requests ) and \
252
252
is_requests_pkg_avail () and \
253
253
_is_handled_by_requests (url ):
254
- s = gen_session (url_params )
254
+ s = gen_session (http_params )
255
255
resp = s .get (url )
256
256
resp .raise_for_status ()
257
257
content_bytes = resp .content
258
258
else :
259
- if url_params and (skip_requests or not is_requests_pkg_avail ()):
260
- msg = 'To utilize url_params , python-requests library is ' + \
259
+ if http_params and (skip_requests or not is_requests_pkg_avail ()):
260
+ msg = 'To utilize http_params , python-requests library is ' + \
261
261
'required but not detected'
262
262
raise ValueError (msg )
263
263
resp = _urlopen (url )
@@ -266,7 +266,7 @@ def fetch_url(url, url_params=None, skip_requests=False):
266
266
267
267
268
268
def get_filepath_or_buffer (filepath_or_buffer , encoding = None ,
269
- compression = None , url_params = None ,
269
+ compression = None , http_params = None ,
270
270
skip_requests = False ):
271
271
"""
272
272
If the filepath_or_buffer is a url, translate and return the buffer.
@@ -281,7 +281,7 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
281
281
compression : str, default None
282
282
indicate the compression such as 'gzip'.
283
283
284
- url_params : dict or requests.Session(), default None
284
+ http_params : dict or requests.Session(), default None
285
285
A python dict containing:
286
286
'auth': tuple (str, str) eg (unae, pwd)
287
287
'auth': Any other auth object accepted by requests
@@ -304,13 +304,13 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
304
304
305
305
Raises
306
306
------
307
- ValueError if url_params specified without installed python-requests pkg
307
+ ValueError if http_params specified without installed python-requests pkg
308
308
"""
309
309
filepath_or_buffer = _stringify_path (filepath_or_buffer )
310
310
311
311
if _is_url (filepath_or_buffer ):
312
312
req , content_bytes = fetch_url (filepath_or_buffer ,
313
- url_params ,
313
+ http_params ,
314
314
skip_requests )
315
315
reader = BytesIO (content_bytes )
316
316
content_encoding = req .headers .get ('Content-Encoding' , None )
0 commit comments