class_docstr: Specify package indexes/Python package sources using Airflow connections.
class_docstr_tok: ["Specify","package","indexes\/Python","package","sources","using","Airflow","connections","."]
docstr: Return a connection URL with basic auth credentials based on connection config.
docstr_tok: ["Return","a","connection","URL","with","basic","auth","credentials","based","on","connection","config","."]
code: def _get_basic_auth_conn_url(
      index_url: str, user: str | None, password: str | None
  ) -> str:
      """Return a connection URL with basic auth credentials based on connection config."""
      url = urlparse(index_url)
      host = url.netloc.split("@")[-1]
      if user:
          if password:
              host = f"{quote(user)}:{quote(password)}@{host}"
          else:
              host = f"{quote(user)}@{host}"
      return url._replace(netloc=host).geturl()
  
file_path: airflow/airflow/hooks/package_index.py
imports: from __future__ import annotations
  import subprocess
  from typing import Any
  from urllib.parse import quote, urlparse
  from airflow.hooks.base import BaseHook
label_desc: Use image node_id 3 for calling the PackageIndexHook obj's underlying member method code with example usage: obj._get_basic_auth_conn_url(index_url, user, password) and returns: url