o
    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	rBd 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d?ddZedZG dd deZededZd@ddZdAddZdBd d!ZdCd%d&Zed'ZdDd+d,ZdEd.d/ZG d0d1 d1eZ G d2d3 d3e Z!ej"d4d5d6G d7d8 d8Z#ej"d4d5d6G d9d: d:Z$ej"d4d5d6G d;d< d<Z%ej"d4d5d6G d=d> d>Z&dS )F    )annotationsN)Mapping)TYPE_CHECKINGAnyProtocolTypeVar)
Collection)      )Self)ArchiveInfoDirInfo	DirectUrlDirectUrlValidationErrorVcsInforeturn	list[str]c                   C  s   t S N)__all__ r   r   U/var/www/html/Deteccion_Ine/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   r/   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:   _DirectUrlRequiredKeyErrorr9   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.Nr4   )r:   r   r   	Exceptionr   )r   r=   r+   r,   er   r   r   _get_objectB   s   rB   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@   )split _PEP610_USER_PASS_ENV_VARS_REGEXmatch)rC   rD   	user_passnetloc_no_user_passr   r   r   _strip_auth_from_netlocS   s   
rM   urlc                 C  s6   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urlsplitrM   rC   
urlunsplitschemepathqueryfragment)rN   rD   
parsed_urlrC   r   r   r   
_strip_url^   s   rX   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   z2Raised when when input data is not spec-compliant.N
str | Noner5   r1   messager4   causestr | Exceptionr   Nonec                C  sT   t |tr |jr|r| d|j n|j| _n|| _|j| _d S || _t|| _d S )N.)r7   r   r5   rZ   r1   )selfr[   r5   r   r   r   __init__v   s   
z!DirectUrlValidationError.__init__c                 C  s   | j r| j d| j S | jS )Nz in )r5   rZ   r_   r   r   r   __str__   s   z DirectUrlValidationError.__str__)r[   r\   r5   rY   r   r]   )r   r1   )r!   r"   r#   __doc__r5   __annotations__r`   rb   r   r   r   r   r   p   s   
 r   c                      s   e Zd Zd fddZ  ZS )r;   r+   r1   r   r]   c                   s   t  jd|d d S )NzMissing required valuer4   )superr`   )r_   r+   	__class__r   r   r`      s   z#_DirectUrlRequiredKeyError.__init__)r+   r1   r   r]   )r!   r"   r#   r`   __classcell__r   r   rf   r   r;      s    r;   TF)frozeninitc                   @  sH   e Zd ZU 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   r1   vcs	commit_idNrY   requested_revision)rm   r   r]   c                C  s.   t | d| t | d| t | d| d S )Nrk   rl   rm   object__setattr__)r_   rk   rl   rm   r   r   r   r`      s   zVcsInfo.__init__r   r   r   c                 C  s&   | t |tdt|tdt |tddS )Nrk   rm   rl   )rk   rm   rl   )r<   r1   r:   r   r   r   r   r      s
   


zVcsInfo._from_dict)rk   r1   rl   r1   rm   rY   r   r]   r    )r!   r"   r#   rd   rm   r`   r$   r   r   r   r   r   r      s   
 r   c                   @  8   e Zd ZU dZded< dddddZedddZdS )r   NMapping[str, str] | Nonehashesrs   r   r]   c                C     t | d| d S )Nrs   rn   )r_   rs   r   r   r   r`         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 )Nrs   c                 s  s    | ]}t |tV  qd S r   )r7   r1   )r*   hr   r   r   	<genexpr>   s    z)ArchiveInfo._from_dict.<locals>.<genexpr>zHash values must be stringsr4   hash=z3Invalid hash format (expected '<algorithm>=<hash>')rG   z
Algorithm z2 used in hash field is not present in hashes fieldz7 used in hash field has different value in hashes fieldrt   )r:   r   allvaluesr   r1   rH   )r   r   rs   Zlegacy_hashhash_algorithm
hash_valuer   r   r   r      s4   



zArchiveInfo._from_dict)rs   rr   r   r]   r    )r!   r"   r#   rs   rd   r`   r$   r   r   r   r   r   r         
 r   c                   @  rq   )r   Nbool | Noneeditabler   r   r]   c                C  ru   )Nr   rn   )r_   r   r   r   r   r`      rv   zDirInfo.__init__r   r   r   c                 C  s   | t |tddS )Nr   r   )r:   boolr   r   r   r   r      s   
zDirInfo._from_dict)r   r   r   r]   r    )r!   r"   r#   r   rd   r`   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   z"A class representing a direct URL.r1   rN   NArchiveInfo | Nonearchive_infoVcsInfo | Nonevcs_infoDirInfo | Nonedir_inforY   subdirectory)r   r   r   r   r   r]   c                C  sJ   t | d| t | d| t | d| t | d| t | d| d S )NrN   r   r   r   r   rn   )r_   rN   r   r   r   r   r   r   r   r`      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rC|jd	sCtd
dd|S )NrN   r   r   r   r   )rN   r   r   r   r   rG   z?Exactly one of vcs_info, archive_info, dir_info must be presentzfile://z3URL scheme must be file:// when dir_info is presentr4   )r<   r1   rB   r   r   r   r:   r   r   r   r   r   rN   
startswith)r   r   
direct_urlr   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_dict   s   
zDirectUrl.from_dictFT)git)generate_legacy_hashstrip_user_passwordrD   r   r   r   rD   rE   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_factoryrz   r   ry   rN   )
dataclassesasdictr.   r   rs   nextiteritemsrX   rN   )r_   r   r   rD   resr}   r~   r   r   r   to_dict%  s   zDirectUrl.to_dictc                 C  s   |  |   dS )zValidate the DirectUrl instance against the specification.

        Raises :class:`DirectUrlValidationError` if invalid.
        N)r   r   ra   r   r   r   validate@  rv   zDirectUrl.validate)rN   r1   r   r   r   r   r   r   r   rY   r   r]   r    )r   r   r   r   rD   rE   r   r   )r   r]   )r!   r"   r#   rc   rd   r   r   r   r   r`   r$   r   r   r   r   r   r   r   r   r      s*   
 r   )r   r   )r'   r(   r   r)   )r   r   r/   r0   r+   r1   r   r2   )r   r   r/   r0   r+   r1   r   r   )r   r   r=   r>   r+   r1   r   r?   )rC   r1   rD   rE   r   r1   )rN   r1   rD   rE   r   r1   )'
__future__r   r   reurllib.parserO   collections.abcr   typingr   r   r   r   sysr   version_infor   Ztyping_extensionsr   r   r   r   r%   r.   r:   r<   rB   compilerI   rM   rX   r@   r   r;   	dataclassr   r   r   r   r   r   r   r   <module>   sH    

	





-