a
    ˆÀàgä  ã                   @   s  d Z ddlZddlZddlmZ ddlmZ ddlm	Z	 e	rhddl
mZmZmZmZmZmZmZ edƒZdZe d	¡Zg d
¢ZG dd„ deƒZddd„Zddd„Zdd„ Zdd„ ZG dd„ deƒZG dd„ deƒZG dd„ deƒZ e	rôeee ef Z!G dd„ deƒZ"dS )z	 PEP 610 é    N)Úsix)Úparse)ÚMYPY_CHECK_RUNNING)ÚAnyÚDictÚIterableÚOptionalÚTypeÚTypeVarÚUnionÚTzdirect_url.jsonz.^\$\{[A-Za-z0-9-_]+\}(:\$\{[A-Za-z0-9-_]+\})?$)Ú	DirectUrlÚDirectUrlValidationErrorÚDirInfoÚArchiveInfoÚVcsInfoc                   @   s   e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__© r   r   úX/var/www/sistema_ama/venv/lib/python3.9/site-packages/pip/_internal/models/direct_url.pyr      s   r   c                 C   sH   || vr|S | | }t jr(|tu r(t j}t||ƒsDtd |||¡ƒ‚|S )z3Get value from dictionary and verify expected type.z-{!r} has unexpected type for {} (expected {}))r   ÚPY2ÚstrÚstring_typesÚ
isinstancer   Úformat©ÚdZexpected_typeÚkeyÚdefaultÚvaluer   r   r   Ú_get    s    
ÿÿr!   c                 C   s(   t | |||ƒ}|d u r$td |¡ƒ‚|S )Nz{} must have a value)r!   r   r   r   r   r   r   Ú_get_required1   s    r"   c                 C   sF   dd„ | D ƒ} | st dƒ‚t| ƒdkr.t dƒ‚| d d us>J ‚| d S )Nc                 S   s   g | ]}|d ur|‘qS ©Nr   )Ú.0Úinfor   r   r   Ú
<listcomp>;   ó    z#_exactly_one_of.<locals>.<listcomp>z/missing one of archive_info, dir_info, vcs_infoé   z1more than one of archive_info, dir_info, vcs_infor   )r   Úlen)Úinfosr   r   r   Ú_exactly_one_of9   s    ÿÿr+   c                  K   s   dd„ |   ¡ D ƒS )z Make dict excluding None values.c                 S   s   i | ]\}}|d ur||“qS r#   r   )r$   ÚkÚvr   r   r   Ú
<dictcomp>K   r'   z _filter_none.<locals>.<dictcomp>)Úitems)Úkwargsr   r   r   Ú_filter_noneH   s    r1   c                   @   s.   e Zd ZdZd	dd„Zedd„ ƒZdd„ ZdS )
r   Úvcs_infoNc                 C   s"   || _ || _|| _|| _|| _d S r#   ©ÚvcsÚrequested_revisionÚ	commit_idÚresolved_revisionÚresolved_revision_type)Úselfr4   r6   r5   r7   r8   r   r   r   Ú__init__Q   s
    zVcsInfo.__init__c              	   C   sF   |d u rd S | t |tdƒt |tdƒt|tdƒt|tdƒt|tdƒd�S )Nr4   r6   r5   r7   r8   )r4   r6   r5   r7   r8   )r"   r   r!   ©Úclsr   r   r   r   Ú
_from_dict_   s    




ûzVcsInfo._from_dictc                 C   s   t | j| j| j| j| jd�S )Nr3   )r1   r4   r5   r6   r7   r8   ©r9   r   r   r   Ú_to_dictl   s    ûzVcsInfo._to_dict)NNN©r   r   r   Únamer:   Úclassmethodr=   r?   r   r   r   r   r   N   s      ú

r   c                   @   s.   e Zd ZdZd	dd„Zedd„ ƒZdd„ ZdS )
r   Úarchive_infoNc                 C   s
   || _ d S r#   ©Úhash)r9   rE   r   r   r   r:   z   s    zArchiveInfo.__init__c                 C   s   |d u rd S | t |tdƒd�S )NrE   rD   )r!   r   r;   r   r   r   r=   €   s    zArchiveInfo._from_dictc                 C   s   t | jd�S )NrD   )r1   rE   r>   r   r   r   r?   ‡   s    zArchiveInfo._to_dict)Nr@   r   r   r   r   r   w   s    þ

r   c                   @   s.   e Zd ZdZd
dd„Zedd„ ƒZdd„ Zd	S )r   Údir_infoFc                 C   s
   || _ d S r#   ©Úeditable)r9   rH   r   r   r   r:   �   s    zDirInfo.__init__c                 C   s"   |d u rd S | t |tddd�d�S )NrH   F)r   rG   )r"   Úboolr;   r   r   r   r=   •   s
    ÿzDirInfo._from_dictc                 C   s   t | jp
d d�S )NrG   )r1   rH   r>   r   r   r   r?   ž   s    zDirInfo._to_dictN)Fr@   r   r   r   r   r   Œ   s    þ

r   c                   @   sZ   e Zd Zddd„Zdd„ Zedd„ ƒZdd	„ Zed
d„ ƒZ	dd„ Z
edd„ ƒZdd„ ZdS )r   Nc                 C   s   || _ || _|| _d S r#   )Úurlr%   Úsubdirectory)r9   rJ   r%   rK   r   r   r   r:   ©   s    zDirectUrl.__init__c                 C   sR   d|vr|S |  dd¡\}}t| jtƒr@| jjdkr@|dkr@|S t |¡rN|S |S )Nú@r(   Úgit)Úsplitr   r%   r   r4   Ú
ENV_VAR_REÚmatch)r9   ÚnetlocÚ	user_passZnetloc_no_user_passr   r   r   Ú_remove_auth_from_netloc³   s    
ÿ
þý
z"DirectUrl._remove_auth_from_netlocc                 C   s8   t  | j¡}|  |j¡}t  |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 ``git``
        in the case of a git URL.
        )
Úurllib_parseÚurlsplitrJ   rS   rQ   Ú
urlunsplitÚschemeÚpathÚqueryÚfragment)r9   ÚpurlrQ   Úsurlr   r   r   Úredacted_urlÂ   s    ÿzDirectUrl.redacted_urlc                 C   s   |   |  ¡ ¡ d S r#   )Ú	from_dictÚto_dictr>   r   r   r   ÚvalidateÐ   s    zDirectUrl.validatec                 C   sR   t t|tdƒt|tdƒtt t|tdƒ¡t t|tdƒ¡t	 t|tdƒ¡gƒd�S )NrJ   rK   rC   rF   r2   )rJ   rK   r%   )
r   r"   r   r!   r+   r   r=   Údictr   r   r;   r   r   r   r^   Ô   s    

ýÿýzDirectUrl.from_dictc                 C   s&   t | j| jd�}| j ¡ || jj< |S )N)rJ   rK   )r1   r]   rK   r%   r?   rA   )r9   Úresr   r   r   r_   ã   s    þzDirectUrl.to_dictc                 C   s   |   t |¡¡S r#   )r^   ÚjsonÚloads)r<   Úsr   r   r   Ú	from_jsonì   s    zDirectUrl.from_jsonc                 C   s   t j|  ¡ dd�S )NT)Ú	sort_keys)rc   Údumpsr_   r>   r   r   r   Úto_jsonñ   s    zDirectUrl.to_json)N)r   r   r   r:   rS   Úpropertyr]   r`   rB   r^   r_   rf   ri   r   r   r   r   r   §   s    ü



	
r   )N)N)#Ú__doc__rc   ÚreÚpip._vendorr   Zpip._vendor.six.moves.urllibr   rT   Úpip._internal.utils.typingr   Útypingr   r   r   r   r	   r
   r   r   ÚDIRECT_URL_METADATA_NAMEÚcompilerO   Ú__all__Ú	Exceptionr   r!   r"   r+   r1   Úobjectr   r   r   ZInfoTyper   r   r   r   r   Ú<module>   s,   $
	

)