def get_netrc_auth(url):
 try:
  locations = (os.path.expanduser('~/{0}'.format(f)) for f in NETRC_FILES)
  netrc_path = None
  for loc in locations:
   if (os.path.exists(loc) and (not netrc_path)):
    netrc_path = loc
  if (netrc_path is None):
   return netrc_path
  ri = urlparse(url)
  host = ri.netloc.split(':')[0]
  try:
   _netrc = netrc(netrc_path).authenticators(host)
   if _netrc:
    login_i = (0 if _netrc[0] else 1)
    return (_netrc[login_i], _netrc[2])
  except (NetrcParseError, IOError):
   pass
 except (ImportError, AttributeError):
  pass

def get_netrc_auth ( url ) : try : locations = ( os . path . expanduser ( '~/{0}' . format ( f ) ) for f in NETRC_FILES ) netrc_path = None for loc in locations : if ( os . path . exists ( loc ) and ( not netrc_path ) ) : netrc_path = loc if ( netrc_path is None ) : return netrc_path ri = urlparse ( url ) host = ri . netloc . split ( ':' ) [ 0 ] try : _netrc = netrc ( netrc_path ) . authenticators ( host ) if _netrc : login_i = ( 0 if _netrc [ 0 ] else 1 ) return ( _netrc [ login_i ] , _netrc [ 2 ] ) except ( NetrcParseError , IOError ) : pass except ( ImportError , AttributeError ) : pass
returns the requests tuple auth for a given url from netrc .