
    .Phs	                         d dl mZ d dlmZ d dlmZmZ d dlmZm	Z	 d dl
mZmZ  G d de          Zded	efd
Z G d de          ZdS )    )sha256)
expandvars)Optional	TypedDict)urlparse
urlunparse)	BaseModel
ConfigDictc                   $    e Zd ZU eed<   eed<   dS )UsernamePasswordDictusernamepasswordN)__name__
__module____qualname__str__annotations__     `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/conda_lock/models/pip_repository.pyr   r   	   s"         MMMMMMMMr   r   urlreturnc                     t          |           }|                    |j                            dd          d                   }t	          |          S )N@   )netloc)r   _replacer   splitr   )r   
parsed_urlstrippeds      r   stripped_urlr"      sI    #J""**;*A*A#q*I*I"*M"NNHhr   c                       e Zd ZU  ed          Zeed<   ededd fd            Ze	defd            Z
e	dee         fd            Ze	defd            Ze	defd	            Ze	defd
            ZdedefdZdS )PipRepositoryT)frozenr   r   c                 "    t          |          S )N)r   )r$   )clsr   s     r   from_stringzPipRepository.from_string   s    %%%%r   c                 N    t          | j                  }|j        dz   |j        z   S )z7The base URL of the pip repository, without a URL path.z://)r   r   schemer   )selffull_urls     r   base_urlzPipRepository.base_url   s'     DH%%&88r   c                     t          | j                  }|j        d S t          |j                  }t          |j        pd          }t          ||          S )N )r   r   )r   r   r   r   r   r   )r+   r    r   r   s       r   expanded_basic_authz!PipRepository.expanded_basic_auth#   sW    dh''
&4j122j17R88#XIIIIr   c                 *    t          | j                  S )z;The base URL of the pip repository, without any basic auth.)r"   r-   r+   s    r   stripped_base_urlzPipRepository.stripped_base_url,   s     DM***r   c                 *    t          | j                  S )z6The URL of the pip repository, without any basic auth.)r"   r   r2   s    r   r"   zPipRepository.stripped_url1   s     DH%%%r   c                     t                      }|                    | j                            d                     |                                S )zPoetry solver requires a name for each repository.

        We use this to match solver results back to their relevant
        repository.
        zutf-8)r   updater   encode	hexdigest)r+   shas     r   namezPipRepository.name6   s;     hh

48??7++,,,}}r   
solver_urlc                 |    |                     | j                  s|S |                    | j        | j        d          S )zNormalize the URL returned by Poetry's solver.

        Poetry doesn't return URLs with URL-based basic Auth, because it gets converted to
        header-based Basic Auth. Because of this, we have to add the auth back in here.
        r   )
startswithr3   replacer-   )r+   r;   s     r   normalize_solver_urlz"PipRepository.normalize_solver_urlA   s@     $$T%;<< 	!!$"8$-KKKr   N)r   r   r   r
   model_configr   r   classmethodr(   propertyr-   r   r   r0   r3   r"   r:   r?   r   r   r   r$   r$      sU        :T***L	HHH&c &o & & & [& 9# 9 9 9 X9
 JX.B%C J J J XJ +3 + + + X+ &c & & & X& c    X	Ls 	Ls 	L 	L 	L 	L 	L 	Lr   r$   N)hashlibr   	posixpathr   typingr   r   urllib.parser   r   pydanticr	   r
   r   r   r"   r$   r   r   r   <module>rH      s                      & & & & & & & & - - - - - - - - * * * * * * * *    9   
 c  c        6L 6L 6L 6L 6LI 6L 6L 6L 6L 6Lr   