@@ -257,13 +257,45 @@ def file_path_to_url(path):
257
257
258
258
259
259
def split_auth_from_url (url_with_uname ):
260
+ """
261
+ If a url contains username and password, it is extracted and returned
262
+ along with a url that does not contain it.
263
+
264
+ Parameters
265
+ ----------
266
+ url_with_uname : a url that may or may not contain username and password
267
+ see section 3.1 RFC 1738 https://www.ietf.org/rfc/rfc1738.txt
268
+ //<user>:<password>@<host>:<port>/<url-path>
269
+
270
+ Returns
271
+ -------
272
+ (username, password), url_no_usrpwd : username or "", password or "",
273
+ url without username or password (if it contained it )
274
+ """
260
275
o = parse_url (url_with_uname )
261
276
usrch = '{}:{}@{}' .format (o .username , o .password , o .hostname )
262
277
url_no_usrpwd = url_with_uname .replace (usrch , o .hostname )
263
278
return (o .username , o .password ), url_no_usrpwd
264
279
265
280
266
281
def get_urlopen_args (url_with_uname , auth = None , verify_ssl = True ):
282
+ """
283
+ generate args to pass to urlopen - including basic auth and and support
284
+ for disabling verification of SSL certificates ( useful where
285
+ self-signed SSL certificates are acceptable security risk -eg: Testing )
286
+
287
+ Parameters
288
+ ----------
289
+ url_with_uname : a url that may or may not contain username and password
290
+ see section 3.1 RFC 1738 https://www.ietf.org/rfc/rfc1738.txt
291
+ //<user>:<password>@<host>:<port>/<url-path>
292
+ auth : ( username/""/None, password/"", None) tuple
293
+ verify_ssl: If False, SSL certificate verification is disabled.
294
+
295
+ Returns
296
+ -------
297
+ Request, kwargs to pass to urlopen. kwargs may be {} or {'context': obj }
298
+ """
267
299
uname = pwd = None
268
300
if auth and len (auth ) == 2 :
269
301
uname , pwd = auth
0 commit comments