Skip to content
Myr

app engine #498

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent bcbc1be · Browse files · 1 file+26 added−20 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+26 added−20 removed

  • other:+26 added−20 removed

1 file+26 added−20 removed

modified:requests/utils.py+26 added-20 removed
35 unmodified lines
3637def get_netrc_auth(url):38 """Returns the Requests tuple auth for a given url from netrc."""3940 try:40 locations = (os.path.expanduser('~/{0}'.format(f)) for f in NETRC_FILES)41 netrc_path = None41 locations = (os.path.expanduser('~/{0}'.format(f)) for f in NETRC_FILES)42 netrc_path = None4343 for loc in locations:44 if os.path.exists(loc) and not netrc_path:45 netrc_path = loc44 for loc in locations:45 if os.path.exists(loc) and not netrc_path:46 netrc_path = loc4747 # Abort early if there isn't one.48 if netrc_path is None:49 return netrc_path48 # Abort early if there isn't one.49 if netrc_path is None:50 return netrc_path5151 ri = urlparse(url)52 ri = urlparse(url)5353 # Strip port numbers from netloc54 host = ri.netloc.split(':')[0]54 # Strip port numbers from netloc55 host = ri.netloc.split(':')[0]5656 try:57 _netrc = netrc(netrc_path).authenticators(host)58 if _netrc:59 # Return with login / password60 login_i = (0 if _netrc[0] else 1)61 return (_netrc[login_i], _netrc[2])62 except (NetrcParseError, IOError, AttributeError):63 # If there was a parsing error or a permissions issue reading the file,64 # we'll just skip netrc auth57 try:58 _netrc = netrc(netrc_path).authenticators(host)59 if _netrc:60 # Return with login / password61 login_i = (0 if _netrc[0] else 1)62 return (_netrc[login_i], _netrc[2])63 except (NetrcParseError, IOError):64 # If there was a parsing error or a permissions issue reading the file,65 # we'll just skip netrc auth66 pass6768 # AppEngine hackiness.69 except AttributeError:70 pass71727374def dict_from_string(s):75 """Returns a MultiDict with Cookies."""7677 cookies = dict()
400 unmodified lines