parameters: (self, original_url)
return_statement: return url, username, password
docstring: Return the credentials to use for the provided URL.
  
          If allowed, netrc and keyring may be used to obtain the
          correct credentials.
  
          Returns (url_without_credentials, username, password). Note
          that even if the original URL contains credentials, this
          function may return a different username and password.
docstring_summary: Return the credentials to use for the provided URL.
docstring_tokens: Return the credentials to use for the provided URL .
function: def _get_url_and_credentials(self, original_url):
          # type: (str) -> Tuple[str, Optional[str], Optional[str]]
          """Return the credentials to use for the provided URL.
  
          If allowed, netrc and keyring may be used to obtain the
          correct credentials.
  
          Returns (url_without_credentials, username, password). Note
          that even if the original URL contains credentials, this
          function may return a different username and password.
          """
          url, netloc, _ = split_auth_netloc_from_url(original_url)
  
          # Use any stored credentials that we have for this netloc
          username, password = self.passwords.get(netloc, (None, None))
  
          if username is None and password is None:
              # No stored credentials. Acquire new credentials without prompting
              # the user. (e.g. from netrc, keyring, or the URL itself)
              username, password = self._get_new_credentials(original_url)
  
          if username is not None or password is not None:
              # Convert the username and password if they're None, so that
              # this netloc will show up as "cached" in the conditional above.
              # Further, HTTPBasicAuth doesn't accept None, so it makes sense to
              # cache the value that is going to be used.
              username = username or ""
              password = password or ""
  
              # Store any acquired credentials.
              self.passwords[netloc] = (username, password)
  
          assert (
              # Credentials were found
              (username is not None and password is not None) or
              # Credentials were not found
              (username is None and password is None)
          ), f"Could not load credentials from url: {original_url}"
  
          return url, username, password
function_tokens: def _get_url_and_credentials ( self , original_url ) : # type: (str) -> Tuple[str, Optional[str], Optional[str]] url , netloc , _ = split_auth_netloc_from_url ( original_url ) # Use any stored credentials that we have for this netloc username , password = self . passwords . get ( netloc , ( None , None ) ) if username is None and password is None : # No stored credentials. Acquire new credentials without prompting # the user. (e.g. from netrc, keyring, or the URL itself) username , password = self . _get_new_credentials ( original_url ) if username is not None or password is not None : # Convert the username and password if they're None, so that # this netloc will show up as "cached" in the conditional above. # Further, HTTPBasicAuth doesn't accept None, so it makes sense to # cache the value that is going to be used. username = username or "" password = password or "" # Store any acquired credentials. self . passwords [ netloc ] = ( username , password ) assert ( # Credentials were found ( username is not None and password is not None ) or # Credentials were not found ( username is None and password is None ) ) , f"Could not load credentials from url: {original_url}" return url , username , password