o
    g¹«j}-  ã                   @  sª  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	rHd dlZd dlmZ d dlmZ ejdkrBd dlmZ nd dlmZ g d	¢ZdEdd„ZedƒZG dd„ deƒZeded�ZdFdd„ZdGdd „ZdHd!d"„ZdId&d'„Ze d(¡ZdJd,d-„ZdKd/d0„ZdLd4d5„Z G d6d7„ d7e!ƒZ"G d8d9„ d9e"ƒZ#ej$d:d;d<�G d=d>„ d>ƒƒZ%ej$d:d;d<�G d?d@„ d@ƒƒZ&ej$d:d;d<�G dAdB„ dBƒƒZ'ej$d:d;d<�G dCdD„ dDƒƒZ(dS )Mé    )ÚannotationsN)ÚMapping)ÚTYPE_CHECKINGÚAnyÚProtocolÚTypeVar)Ú
Collection)ÚSplitResult)é   é   )ÚSelf)ÚArchiveInfoÚDirInfoÚ	DirectUrlÚDirectUrlValidationErrorÚVcsInfoÚreturnú	list[str]c                   C  s   t S ©N)Ú__all__© r   r   úT/var/www/html/laksyashrimp/venv/lib/python3.10/site-packages/packaging/direct_url.pyÚ__dir__   ó   r   Ú_Tc                   @  s   e Zd Zeddd„ƒZdS )	Ú_FromMappingProtocolÚdúMapping[str, Any]r   r   c                 C  s   d S r   r   ©Úclsr   r   r   r   Ú
_from_dict$   r   z_FromMappingProtocol._from_dictN©r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Úclassmethodr    r   r   r   r   r   #   s    r   Ú_FromMappingProtocolT)ÚboundÚdataúlist[tuple[str, Any]]údict[str, Any]c                 C  s   dd„ | D ƒS )Nc                 S  s   i | ]\}}|d ur||“qS r   r   )Ú.0ÚkeyÚvaluer   r   r   Ú
<dictcomp>,   s    z&_json_dict_factory.<locals>.<dictcomp>r   )r(   r   r   r   Ú_json_dict_factory+   s   r/   r   r   Úexpected_typeútype[_T]r,   Ústrú	_T | Nonec                 C  sF   |   |¡ }du rdS t||ƒs!tdt|ƒj› d|j› d�|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   r0   r,   r-   r   r   r   Ú_get/   s   
ÿýr;   c                 C  s    t | ||ƒ }du rt|ƒ‚|S )zKGet a required value from the dictionary and verify it's the expected type.N)r;   Ú_DirectUrlRequiredKeyErrorr:   r   r   r   Ú_get_required<   s   r=   Útarget_typeútype[_FromMappingProtocolT]ú_FromMappingProtocolT | Nonec              
   C  sL   t | t|ƒ }du rdS z| |¡W S  ty% } zt||d�|‚d}~ww )zIGet a dictionary value from the dictionary and convert it to a dataclass.Nr5   )r;   r   r    Ú	Exceptionr   )r   r>   r,   r-   Úer   r   r   Ú_get_objectC   s   €ÿrC   z.^\$\{[A-Za-z0-9-_]+\}(:\$\{[A-Za-z0-9-_]+\})?$ÚnetlocÚsafe_user_passwordsúCollection[str]c                 C  s:   d| vr| S |   dd¡\}}||v r| S t |¡r| S |S )Nú@é   )ÚrsplitÚ _PEP610_USER_PASS_ENV_VARS_REGEXÚmatch)rD   rE   Ú	user_passÚnetloc_no_user_passr   r   r   Ú_strip_auth_from_netlocT   s   
rN   Úurlc                 C  s6   t j | ¡}t|j|ƒ}t j |j||j|j|j	f¡S )z¥url 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ÚurlsplitrN   rD   Ú
urlunsplitÚschemeÚpathÚqueryÚfragment)rO   rE   Ú
parsed_urlrD   r   r   r   Ú
_strip_url_   s   ûÿrY   rX   r	   Úboolc                 C  s   | j  d¡S )Nú/)rU   Ú
startswith)rX   r   r   r   Ú_file_url_has_absolute_pathq   s   r]   c                   @  s@   e Zd ZU dZdZded< ded< ddœddd„Zddd„ZdS )r   zSRaised when when input data is not spec-compliant.

    .. versionadded:: 26.1
    Nú
str | Noner6   r2   Úmessager5   Úcauseústr | Exceptionr   ÚNonec                C  sT   t |tƒr |jr|r|› d|j› �n|j| _n|| _|j| _d S || _t|ƒ| _d S )NÚ.)r8   r   r6   r_   r2   )Úselfr`   r6   r   r   r   Ú__init__~   s   
ÿz!DirectUrlValidationError.__init__c                 C  s   | j r| j› d| j ›�S | jS )Nz in )r6   r_   ©rd   r   r   r   Ú__str__�   s   z DirectUrlValidationError.__str__)r`   ra   r6   r^   r   rb   )r   r2   )r"   r#   r$   Ú__doc__r6   Ú__annotations__re   rg   r   r   r   r   r   u   s   
 ür   c                      s   e Zd Zd‡ fdd„Z‡  ZS )r<   r,   r2   r   rb   c                   s   t ƒ jd|d� d S )NzMissing required valuer5   )Úsuperre   )rd   r,   ©Ú	__class__r   r   re   —   s   z#_DirectUrlRequiredKeyError.__init__)r,   r2   r   rb   )r"   r#   r$   re   Ú__classcell__r   r   rk   r   r<   –   s    r<   TF)ÚfrozenÚinitc                   @  sL   e Zd ZU dZded< ded< dZded< ddœddd„Zeddd„ƒZdS )r   z8The version control information of a :class:`DirectUrl`.r2   ÚvcsÚ	commit_idNr^   Úrequested_revision)rr   r   rb   c                C  s.   t  | d|¡ t  | d|¡ t  | d|¡ d S )Nrp   rq   rr   ©ÚobjectÚ__setattr__)rd   rp   rq   rr   r   r   r   re   £   s   zVcsInfo.__init__r   r   r   c                 C  s&   | t |tdƒt|tdƒt |tdƒd�S )Nrp   rr   rq   )rp   rr   rq   )r=   r2   r;   r   r   r   r   r    ®   s
   


ýzVcsInfo._from_dict)rp   r2   rq   r2   rr   r^   r   rb   r!   )	r"   r#   r$   rh   ri   rr   re   r%   r    r   r   r   r   r   ›   s   
 ûr   c                   @  ó<   e Zd ZU dZdZded< ddœddd	„Zeddd„ƒZdS )r   z0The archive information of a :class:`DirectUrl`.NúMapping[str, str] | NoneÚhashes©rx   r   rb   c                C  ó   t  | d|¡ d S )Nrx   rs   )rd   rx   r   r   r   re   ¾   ó   zArchiveInfo.__init__r   r   r   c                 C  sÆ   t |tdƒ}|d urtdd„ | ¡ D ƒƒstddd�‚t |tdƒ}|d ur^d|vr/tddd�‚| dd	¡\}}|d u r@||i}n||vrNtd
|›d�dd�‚|| |kr^td
|›d�dd�‚| |d�S )Nrx   c                 s  s   � | ]}t |tƒV  qd S r   )r8   r2   )r+   Úhr   r   r   Ú	<genexpr>È   s   € z)ArchiveInfo._from_dict.<locals>.<genexpr>zHash values must be stringsr5   Úhashú=z3Invalid hash format (expected '<algorithm>=<hash>')rH   z
Algorithm z2 used in hash field is not present in hashes fieldz7 used in hash field has different value in hashes fieldry   )r;   r   ÚallÚvaluesr   r2   Úsplit)r   r   rx   Úlegacy_hashÚhash_algorithmÚ
hash_valuer   r   r   r    Å   s4   ÿþ

ý
ý
zArchiveInfo._from_dict)rx   rw   r   rb   r!   )	r"   r#   r$   rh   rx   ri   re   r%   r    r   r   r   r   r   ¸   ó   
 ýr   c                   @  rv   )r   z8The local directory information of a :class:`DirectUrl`.Núbool | NoneÚeditable©rˆ   r   rb   c                C  rz   )Nrˆ   rs   )rd   rˆ   r   r   r   re   î   r{   zDirInfo.__init__r   r   r   c                 C  s   | t |tdƒd�S )Nrˆ   r‰   )r;   rZ   r   r   r   r   r    õ   s   
ÿzDirInfo._from_dict)rˆ   r‡   r   rb   r!   )	r"   r#   r$   rh   rˆ   ri   re   r%   r    r   r   r   r   r   è   r†   r   c                   @  sš   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d„Z	e
d'dd„ƒZe
d'dd„ƒZddddœd(d"d#„Zd)d$d%„ZdS )*r   zCA class representing a direct URL.

    .. versionadded:: 26.1
    r2   rO   NúArchiveInfo | NoneÚarchive_infoúVcsInfo | NoneÚvcs_infoúDirInfo | NoneÚdir_infor^   Úsubdirectory)r‹   r�   r�   r�   r   rb   c                C  sJ   t  | d|¡ t  | d|¡ t  | d|¡ t  | d|¡ t  | d|¡ d S )NrO   r‹   r�   r�   r�   rs   )rd   rO   r‹   r�   r�   r�   r   r   r   re   	  s
   	zDirectUrl.__init__r   r   r   c              	   C  sª   | t |tdƒt|tdƒt|tdƒt|tdƒt|tdƒd�}t|jƒt|j	ƒ t|j
ƒ dkr2tdƒ‚|j
d urStj |j¡}|jd	krItd
dd�‚t|ƒsStddd�‚|S )NrO   r‹   r�   r�   r�   )rO   r‹   r�   r�   r�   rH   z?Exactly one of vcs_info, archive_info, dir_info must be presentÚfilez3URL scheme must be file:// when dir_info is presentr5   z2File URL must be absolute when dir_info is present)r=   r2   rC   r   r   r   r;   rZ   r�   r‹   r�   r   rP   rQ   rR   rO   rT   r]   )r   r   Ú
direct_urlrX   r   r   r   r      s<   




ûÿþüÿ

þþzDirectUrl._from_dictc                C  s
   |   |¡S )z@Create and validate a DirectUrl instance from a JSON dictionary.)r    r   r   r   r   Ú	from_dict8  s   
zDirectUrl.from_dictFT)Úgit)Úgenerate_legacy_hashÚstrip_user_passwordrE   r•   rZ   r–   rE   rF   c                C  sf   t j| td�}|r'| jr'| jjr'tt| jj ¡ ƒƒ\}}|› d|› �|d d< |r1t| 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~   rO   )
ÚdataclassesÚasdictr/   r‹   rx   ÚnextÚiterÚitemsrY   rO   )rd   r•   r–   rE   Úresr„   r…   r   r   r   Úto_dict=  s   zDirectUrl.to_dictc                 C  s   |   |  ¡ ¡ dS )z�Validate the DirectUrl instance against the specification.

        Raises :class:`DirectUrlValidationError` if invalid.
        N)r“   rž   rf   r   r   r   ÚvalidateX  r{   zDirectUrl.validate)rO   r2   r‹   rŠ   r�   rŒ   r�   rŽ   r�   r^   r   rb   r!   )r•   rZ   r–   rZ   rE   rF   r   r   )r   rb   )r"   r#   r$   rh   ri   r‹   r�   r�   r�   re   r%   r    r“   rž   rŸ   r   r   r   r   r   ü   s*   
 ùûr   )r   r   )r(   r)   r   r*   )r   r   r0   r1   r,   r2   r   r3   )r   r   r0   r1   r,   r2   r   r   )r   r   r>   r?   r,   r2   r   r@   )rD   r2   rE   rF   r   r2   )rO   r2   rE   rF   r   r2   )rX   r	   r   rZ   ))Ú
__future__r   r˜   ÚreÚurllib.parserP   Úcollections.abcr   Útypingr   r   r   r   Úsysr   r	   Úversion_infor   Útyping_extensionsr   r   r   r   r&   r/   r;   r=   rC   ÚcompilerJ   rN   rY   r]   rA   r   r<   Ú	dataclassr   r   r   r   r   r   r   r   Ú<module>   sL    

	



ÿ


!/