
    j}-                       d dl mZ d dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZmZ e	r(d dlZd dlmZ d dlmZ ej        dk    rd dlmZ nd dlmZ g d	Zd=dZ ed          Z G d de          Z ede          Zd>dZd?dZd@dZdAd"Z ej        d#          ZdBd'ZdCd)ZdDd-Z  G d. d/e!          Z" G d0 d1e"          Z# ej$        d2d34           G d5 d6                      Z% ej$        d2d34           G d7 d8                      Z& ej$        d2d34           G d9 d:                      Z' ej$        d2d34           G d; d<                      Z(dS )E    )annotationsN)Mapping)TYPE_CHECKINGAnyProtocolTypeVar)
Collection)SplitResult)      )Self)ArchiveInfoDirInfo	DirectUrlDirectUrlValidationErrorVcsInforeturn	list[str]c                     t           S N)__all__     S/var/www/html/python-test/venv/lib/python3.11/site-packages/packaging/direct_url.py__dir__r      s    Nr   _Tc                  &    e Zd Zedd            ZdS )_FromMappingProtocoldMapping[str, Any]r   r   c                    d S r   r   clsr   s     r   
_from_dictz_FromMappingProtocol._from_dict$   s    7:sr   Nr   r    r   r   )__name__
__module____qualname__classmethodr$   r   r   r   r   r   #   s&        ::: [:::r   r   _FromMappingProtocolT)bounddatalist[tuple[str, Any]]dict[str, Any]c                    d | D             S )Nc                    i | ]
\  }}|||S r   r   ).0keyvalues      r   
<dictcomp>z&_json_dict_factory.<locals>.<dictcomp>,   s#    CCC:31BC1B1B1Br   r   )r,   s    r   _json_dict_factoryr5   +   s    CCCCCCr   r   r    expected_typetype[_T]r2   str	_T | Nonec                    |                      |          x}dS t          ||          s/t          dt          |          j         d|j         d|          |S )zBGet a value from the dictionary and verify it's the expected type.NzUnexpected type z (expected )context)get
isinstancer   typer&   r   r6   r2   r3   s       r   _getrB   /   s~    s$te]++ 
&3tE{{3 3 3&/3 3 3
 
 
 	

 Lr   c                J    t          | ||          x}t          |          |S )zKGet a required value from the dictionary and verify it's the expected type.)rB   _DirectUrlRequiredKeyErrorrA   s       r   _get_requiredrE   <   s,    a,,,5(---Lr   target_typetype[_FromMappingProtocolT]_FromMappingProtocolT | Nonec                    t          | t          |          x}dS 	 |                    |          S # t          $ r}t	          ||          |d}~ww xY w)zIGet a dictionary value from the dictionary and convert it to a dataclass.Nr<   )rB   r   r$   	Exceptionr   )r   rF   r2   r3   es        r   _get_objectrL   C   sm     a#&&&/t>%%e,,, > > >&q#666A=>s   1 
AAAz.^\$\{[A-Za-z0-9-_]+\}(:\$\{[A-Za-z0-9-_]+\})?$netlocsafe_user_passwordsCollection[str]c                    d| vr| S |                      dd          \  }}||v r| S t                              |          r| S |S )N@   )rsplit _PEP610_USER_PASS_ENV_VARS_REGEXmatch)rM   rN   	user_passnetloc_no_user_passs       r   _strip_auth_from_netlocrX   T   s]    
&%+]]3%:%:"I"''''--i88 r   urlc                    t           j                            |           }t          |j        |          }t           j                            |j        ||j        |j        |j	        f          S )zurl with user:password part removed unless it is formed with
    environment variables as specified in PEP 610, or it is a safe user:password
    such as `git`.
    )
urllibparseurlsplitrX   rM   
urlunsplitschemepathqueryfragment)rY   rN   
parsed_urlrM   s       r   
_strip_urlrd   _   se    
 &&s++J$Z%68KLLF<""O	
  r   rc   r
   boolc                6    | j                             d          S )N/)r`   
startswith)rc   s    r   _file_url_has_absolute_pathri   q   s    ?%%c***r   c                  B    e Zd ZU dZdZded<   ded<   ddddZddZdS )r   zSRaised when when input data is not spec-compliant.

    .. versionadded:: 26.1
    N
str | Noner=   r8   messager<   causestr | Exceptionr   Nonec                   t          |t                    r7|j        r|r| d|j         n|j        | _        n|| _        |j        | _        d S || _        t	          |          | _        d S )N.)r?   r   r=   rl   r8   )selfrm   r=   s      r   __init__z!DirectUrlValidationError.__init__~   sw     e566 
	&} '4;Nw00000   ' =DLLL"DLu::DLLLr   c                @    | j         r| j         d| j         S | j        S )Nz in )r=   rl   rr   s    r   __str__z DirectUrlValidationError.__str__   s,    < 	9l88888|r   )rm   rn   r=   rk   r   ro   )r   r8   )r&   r'   r(   __doc__r=   __annotations__rs   rv   r   r   r   r   r   u   ss          
 GLLL #	& & & & & &$     r   r   c                        e Zd Zd fdZ xZS )rD   r2   r8   r   ro   c                N    t                                          d|           d S )NzMissing required valuer<   )superrs   )rr   r2   	__class__s     r   rs   z#_DirectUrlRequiredKeyError.__init__   s'    13?????r   )r2   r8   r   ro   )r&   r'   r(   rs   __classcell__)r|   s   @r   rD   rD      sG        @ @ @ @ @ @ @ @ @ @r   rD   TF)frozeninitc                  \    e Zd ZU dZded<   ded<   dZded<   ddddZedd            ZdS )r   z8The version control information of a :class:`DirectUrl`.r8   vcs	commit_idNrk   requested_revision)r   r   ro   c                   t                               | d|           t                               | d|           t                               | d|           d S )Nr   r   r   object__setattr__)rr   r   r   r   s       r   rs   zVcsInfo.__init__   sT     	4,,,4i8884!57IJJJJJr   r   r    r   c           	          | t          |t          d          t          |t          d          t          |t          d                    S )Nr   r   r   )r   r   r   )rE   r8   rB   r"   s     r   r$   zVcsInfo._from_dict   sK     sae,,#As,@AA#AsK88
 
 
 	
r   )r   r8   r   r8   r   rk   r   ro   r%   )	r&   r'   r(   rw   rx   r   rs   r)   r$   r   r   r   r   r      s         BBHHHNNN%))))) *.	K 	K 	K 	K 	K 	K 
 
 
 [
 
 
r   r   c                  H    e Zd ZU dZdZded<   ddddZedd            ZdS )r   z0The archive information of a :class:`DirectUrl`.NMapping[str, str] | Nonehashesr   r   ro   c               >    t                               | d|           d S )Nr   r   )rr   r   s     r   rs   zArchiveInfo.__init__   s"    
 	4622222r   r   r    r   c                   t          |t          d          }|<t          d |                                D                       st	          dd          t          |t
          d          }|od|vrt	          dd          |                    dd          \  }}|||i}n:||vrt	          d	|d
d          ||         |k    rt	          d	|dd           | |          S )Nr   c              3  @   K   | ]}t          |t                    V  d S r   )r?   r8   )r1   hs     r   	<genexpr>z)ArchiveInfo._from_dict.<locals>.<genexpr>   s,      )V)V*Q*<*<)V)V)V)V)V)Vr   zHash values must be stringsr<   hash=z3Invalid hash format (expected '<algorithm>=<hash>')rR   z
Algorithm z2 used in hash field is not present in hashes fieldz7 used in hash field has different value in hashes fieldr   )rB   r   allvaluesr   r8   split)r#   r   r   legacy_hashhash_algorithm
hash_values         r   r$   zArchiveInfo._from_dict   s[   a(++c)V)Vfmmoo)V)V)V&V&V*-x    1c6**"+%%.I"    *5):):3)B)B&NJ~(*5 "//2:^ : : : (   
 .)Z772?^ ? ? ? &   
 s&!!!!r   )r   r   r   ro   r%   )	r&   r'   r(   rw   r   rx   rs   r)   r$   r   r   r   r   r      sp         ::'+F++++
 ,03 3 3 3 3 3 " " " [" " "r   r   c                  H    e Zd ZU dZdZded<   ddddZedd            ZdS )r   z8The local directory information of a :class:`DirectUrl`.Nbool | Noneeditabler   r   ro   c               >    t                               | d|           d S )Nr   r   )rr   r   s     r   rs   zDirInfo.__init__   s"    
 	4X66666r   r   r    r   c                B     | t          |t          d                    S )Nr   r   )rB   re   r"   s     r   r$   zDirInfo._from_dict   s*    s!T:..
 
 
 	
r   )r   r   r   ro   r%   )	r&   r'   r(   rw   r   rx   rs   r)   r$   r   r   r   r   r      sp         BB H    
 !%7 7 7 7 7 7 
 
 
 [
 
 
r   r   c                      e Zd ZU dZded<   dZded<   dZded<   dZd	ed
<   dZded<   dddddd!dZ	e
d"d            Ze
d"d            Zddddd#dZd$d ZdS )%r   zCA class representing a direct URL.

    .. versionadded:: 26.1
    r8   rY   NArchiveInfo | Nonearchive_infoVcsInfo | Nonevcs_infoDirInfo | Nonedir_infork   subdirectory)r   r   r   r   r   ro   c                  t                               | d|           t                               | d|           t                               | d|           t                               | d|           t                               | d|           d S )NrY   r   r   r   r   r   )rr   rY   r   r   r   r   s         r   rs   zDirectUrl.__init__	  s     	4,,,4>>>4X6664X6664>>>>>r   r   r    r   c                ^    | t          |t          d          t          |t          d          t          |t          d          t          |t
          d          t          |t          d                    }t          |j                  t          |j	                  z   t          |j
                  z   dk    rt          d          |j
        `t          j                            |j                  }|j        d	k    rt          d
d          t#          |          st          dd          |S )NrY   r   r   r   r   )rY   r   r   r   r   rR   z?Exactly one of vcs_info, archive_info, dir_info must be presentfilez3URL scheme must be file:// when dir_info is presentr<   z2File URL must be absolute when dir_info is present)rE   r8   rL   r   r   r   rB   re   r   r   r   r   r[   r\   r]   rY   r_   ri   )r#   r   
direct_urlrc   s       r   r$   zDirectUrl._from_dict  sC   Sae,,$Q^DD GZ88 GZ88an55
 
 

 $%%:*++,:&''( 	 
 +Q   *..z~>>J F**.I!    /z:: .H!   
 r   c               ,    |                      |          S )z@Create and validate a DirectUrl instance from a JSON dictionary.)r$   r"   s     r   	from_dictzDirectUrl.from_dict8  s     ~~a   r   FT)git)generate_legacy_hashstrip_user_passwordrN   r   re   r   rN   rO   c               0   t          j        | t                    }|r^| j        rW| j        j        rKt          t          | j        j                                                            \  }}| d| |d         d<   |rt          | j	        |          |d<   |S )a  Convert the DirectUrl instance to a JSON dictionary.

        :param generate_legacy_hash: If True, include a legacy `hash` field in
            `archive_info` for backward compatibility with tools that don't
            support the `hashes` field.
        :param strip_user_password: If True, strip user:password from the URL
            unless it is formed with environment variables as specified in PEP
            610, or it is a safe user:password such as `git`.
        :param safe_user_passwords: A collection of user:password strings that
            should not be stripped from the URL even if `strip_user_password` is
            True.
        )dict_factoryr   r   r   rY   )
dataclassesasdictr5   r   r   nextiteritemsrd   rY   )rr   r   r   rN   resr   r   s          r   to_dictzDirectUrl.to_dict=  s    &  4FGGG 	KD$5 	K$:K:R 	K)-d43D3K3Q3Q3S3S.T.T)U)U&NJ-;*J*Jj*J*JC' 	C#DH.ABBCJ
r   c                T    |                      |                                            dS )zValidate the DirectUrl instance against the specification.

        Raises :class:`DirectUrlValidationError` if invalid.
        N)r   r   ru   s    r   validatezDirectUrl.validateX  s$    
 	t||~~&&&&&r   )rY   r8   r   r   r   r   r   r   r   rk   r   ro   r%   )r   re   r   re   rN   rO   r   r    )r   ro   )r&   r'   r(   rw   rx   r   r   r   r   rs   r)   r$   r   r   r   r   r   r   r   r      s         
 HHH'+L++++#H#####H#####L#### ,0#'#'#'? ? ? ? ? ?    [> ! ! ! [! &+$(/7     6' ' ' ' ' 'r   r   )r   r   )r,   r-   r   r.   )r   r    r6   r7   r2   r8   r   r9   )r   r    r6   r7   r2   r8   r   r   )r   r    rF   rG   r2   r8   r   rH   )rM   r8   rN   rO   r   r8   )rY   r8   rN   rO   r   r8   )rc   r
   r   re   ))
__future__r   r   reurllib.parser[   collections.abcr   typingr   r   r   r   sysr	   r
   version_infor   typing_extensionsr   r   r   r   r*   r5   rB   rE   rL   compilerT   rX   rd   ri   rJ   r   rD   	dataclassr   r   r   r   r   r   r   <module>r      s   " " " " " "     				     # # # # # # 8 8 8 8 8 8 8 8 8 8 8 8 +JJJ******((((((
7""******      WT]]; ; ; ; ;8 ; ; ;
   7?STTT D D D D
 
 
 
   	> 	> 	> 	> $.2:5$ $  
      $+ + + +    y   B@ @ @ @ @!9 @ @ @
 d///
 
 
 
 
 
 
 0/
8 d///," ," ," ," ," ," ," 0/,"^ d///
 
 
 
 
 
 
 0/
& d///`' `' `' `' `' `' `' 0/`' `' `'r   