
    bi*                       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 ej        dk    rd dlmZ nd dlmZ g dZd8dZ ed          Z G d de          Z ede          Zd9dZd:dZd;dZd<d!Z ej        d"          Zd=d&Zd>d(Z G d) d*e          Z  G d+ d,e           Z! ej"        d-d./           G d0 d1                      Z# ej"        d-d./           G d2 d3                      Z$ ej"        d-d./           G d4 d5                      Z% ej"        d-d./           G d6 d7                      Z&dS )?    )annotationsN)Mapping)TYPE_CHECKINGAnyProtocolTypeVar)
Collection)      )Self)ArchiveInfoDirInfo	DirectUrlDirectUrlValidationErrorVcsInforeturn	list[str]c                     t           S N)__all__     l/home/jenkins/jenkins/workspace/simtester-sanitize/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_factoryr4   *   s    CCCCCCr   r   r   expected_typetype[_T]r1   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   r5   r1   r2   s       r   _getrA   .   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.)rA   _DirectUrlRequiredKeyErrorr@   s       r   _get_requiredrD   ;   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;   )rA   r   r#   	Exceptionr   )r   rE   r1   r2   es        r   _get_objectrK   B   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@   )split _PEP610_USER_PASS_ENV_VARS_REGEXmatch)rL   rM   	user_passnetloc_no_user_passs       r   _strip_auth_from_netlocrW   S   s]    
&%+\\#q%9%9"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urlsplitrW   rL   
urlunsplitschemepathqueryfragment)rX   rM   
parsed_urlrL   s       r   
_strip_urlrc   ^   se    
 &&s++J$Z%68KLLF<""O	
  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   z2Raised when when input data is not spec-compliant.N
str | Noner<   r7   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<   rf   r7   )selfrg   r<   s      r   __init__z!DirectUrlValidationError.__init__v   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<   rf   rl   s    r   __str__z DirectUrlValidationError.__str__   s,    < 	9l88888|r   )rg   rh   r<   re   r   ri   )r   r7   )r%   r&   r'   __doc__r<   __annotations__rm   rp   r   r   r   r   r   p   sm         <<GLLL #	& & & & & &$     r   r   c                        e Zd Zd fdZ xZS )rC   r1   r7   r   ri   c                N    t                                          d|           d S )NzMissing required valuer;   )superrm   )rl   r1   	__class__s     r   rm   z#_DirectUrlRequiredKeyError.__init__   s'    13?????r   )r1   r7   r   ri   )r%   r&   r'   rm   __classcell__)rv   s   @r   rC   rC      sG        @ @ @ @ @ @ @ @ @ @r   rC   TF)frozeninitc                  X    e Zd ZU ded<   ded<   dZded<   dddd
Zedd            ZdS )r   r7   vcs	commit_idNre   requested_revision)r}   r   ri   c                   t                               | d|           t                               | d|           t                               | d|           d S )Nr{   r|   r}   object__setattr__)rl   r{   r|   r}   s       r   rm   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|   )rD   r7   rA   r!   s     r   r#   zVcsInfo._from_dict   sK     sae,,#As,@AA#AsK88
 
 
 	
r   )r{   r7   r|   r7   r}   re   r   ri   r$   )r%   r&   r'   rr   r}   rm   r(   r#   r   r   r   r   r      s         HHHNNN%))))) *.	K 	K 	K 	K 	K 	K 
 
 
 [
 
 
r   r   c                  D    e Zd ZU dZded<   ddddZedd            ZdS )r   NMapping[str, str] | Nonehashesr   r   ri   c               >    t                               | d|           d S )Nr   r   )rl   r   s     r   rm   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>   r7   )r0   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>')rQ   z
Algorithm z2 used in hash field is not present in hashes fieldz7 used in hash field has different value in hashes fieldr   )rA   r   allvaluesr   r7   rR   )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   ri   r$   )r%   r&   r'   r   rr   rm   r(   r#   r   r   r   r   r      sj         '+F++++
 ,03 3 3 3 3 3 " " " [" " "r   r   c                  D    e Zd ZU dZded<   ddddZedd            ZdS )r   Nbool | Noneeditabler   r   ri   c               >    t                               | d|           d S )Nr   r   )rl   r   s     r   rm   zDirInfo.__init__   s"    
 	4X66666r   r   r   r   c                B     | t          |t          d                    S )Nr   r   )rA   boolr!   s     r   r#   zDirInfo._from_dict   s*    s!T:..
 
 
 	
r   )r   r   r   ri   r$   )r%   r&   r'   r   rr   rm   r(   r#   r   r   r   r   r      sj          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   z"A class representing a direct URL.r7   rX   NArchiveInfo | Nonearchive_infoVcsInfo | Nonevcs_infoDirInfo | Nonedir_infore   subdirectory)r   r   r   r   r   ri   c                  t                               | d|           t                               | d|           t                               | d|           t                               | d|           t                               | d|           d S )NrX   r   r   r   r   r   )rl   rX   r   r   r   r   s         r   rm   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
        +|j                            d	          st          d
d          |S )NrX   r   r   r   r   )rX   r   r   r   r   rQ   z?Exactly one of vcs_info, archive_info, dir_info must be presentzfile://z3URL scheme must be file:// when dir_info is presentr;   )rD   r7   rK   r   r   r   rA   r   r   r   r   r   rX   
startswith)r"   r   
direct_urls      r   r#   zDirectUrl._from_dict  s   Sae,,$Q^DD GZ88 GZ88an55
 
 

 $%%:*++,:&''( 	 
 +Q   *:>3L3LY3W3W**E   
 r   c               ,    |                      |          S )z@Create and validate a DirectUrl instance from a JSON dictionary.)r#   r!   s     r   	from_dictzDirectUrl.from_dict   s     ~~a   r   FT)git)generate_legacy_hashstrip_user_passwordrM   r   r   r   rM   rN   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   rX   )
dataclassesasdictr4   r   r   nextiteritemsrc   rX   )rl   r   r   rM   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   ro   s    r   validatezDirectUrl.validate@  s$    
 	t||~~&&&&&r   )rX   r7   r   r   r   r   r   r   r   re   r   ri   r$   )r   r   r   r   rM   rN   r   r   )r   ri   )r%   r&   r'   rq   rr   r   r   r   r   rm   r(   r#   r   r   r   r   r   r   r   r      s        ,,HHH'+L++++#H#####H#####L#### ,0#'#'#'? ? ? ? ? ?    [0 ! ! ! [! &+$(/7     6' ' ' ' ' 'r   r   )r   r   )r+   r,   r   r-   )r   r   r5   r6   r1   r7   r   r8   )r   r   r5   r6   r1   r7   r   r   )r   r   rE   rF   r1   r7   r   rG   )rL   r7   rM   rN   r   r7   )rX   r7   rM   rN   r   r7   )'
__future__r   r   reurllib.parserZ   collections.abcr   typingr   r   r   r   sysr	   version_infor   typing_extensionsr   r   r   r   r)   r4   rA   rD   rK   compilerS   rW   rc   rI   r   rC   	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   <@ @ @ @ @!9 @ @ @
 d///
 
 
 
 
 
 
 0/
4 d///*" *" *" *" *" *" *" 0/*"Z d///
 
 
 
 
 
 
 0/
" d///V' V' V' V' V' V' V' 0/V' V' V'r   