Your IP : 216.73.216.189


Current Path : /snap/certbot/5603/lib/python3.12/site-packages/packaging/__pycache__/
Upload File :
Current File : //snap/certbot/5603/lib/python3.12/site-packages/packaging/__pycache__/direct_url.cpython-312.pyc

�

�j�*��~�ddlmZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZe	r&ddl
Z
ddlmZe
jdk\rddlmZnddlmZgd�Zd%d	�Zed
�ZGd�de�Zed
e��Zd&d�Zd'd�Zd(d�Z								d)d�Zej6d�Zd*d�Zd+d�ZGd�de�Z Gd�de �Z!ejDdd��Gd�d��Z#ejDdd��Gd�d ��Z$ejDdd��Gd!�d"��Z%ejDdd��Gd#�d$��Z&y),�)�annotationsN)�Mapping)�
TYPE_CHECKING�Any�Protocol�TypeVar)�
Collection)��)�Self)�ArchiveInfo�DirInfo�	DirectUrl�DirectUrlValidationError�VcsInfoc��tS�N)�__all__����/build/snapcraft-certbot-54d6d23c1eba5f776fc280588daee8b3/parts/certbot/install/lib/python3.12/site-packages/packaging/direct_url.py�__dir__rs���Nr�_Tc��eZdZedd��Zy)�_FromMappingProtocolc��yrr��cls�ds  r�
_from_dictz_FromMappingProtocol._from_dict#s��7:rN�r�Mapping[str, Any]�returnr)�__name__�
__module__�__qualname__�classmethodr rrrrr"s���:��:rr�_FromMappingProtocolT)�boundc�@�|D��cic]\}}|��	||��
c}}Scc}}wrr)�data�key�values   r�_json_dict_factoryr.*s#��)-�C�:�3���1B�C��J�C�C��Cs�
�c��|j|�x}�yt||�s1tdt|�j�d|j�d�|���|S)zBGet a value from the dictionary and verify it's the expected type.NzUnexpected type z (expected �)��context)�get�
isinstancer�typer$�r�
expected_typer,r-s    r�_getr8.sc�����s����$���e�]�+�&��t�E�{�3�3�4�5�&�/�/�0��
3��
�	
�
�Lrc�:�t|||�x}�t|��|S)zKGet a required value from the dictionary and verify it's the expected type.)r8�_DirectUrlRequiredKeyErrorr6s    r�
_get_requiredr;;s&���a���,�,��5�(��-�-��Lrc��t|t|�x}�y	|j|�S#t$r}t	||��|�d}~wwxYw)zIGet a dictionary value from the dictionary and convert it to a dataclass.Nr1)r8rr �	Exceptionr)r�target_typer,r-�es     r�_get_objectr@BsP���a��#�&�&��/��>��%�%�e�,�,���>�&�q�#�6�A�=��>�s�'�	A�>�Az.^\$\{[A-Za-z0-9-_]+\}(:\$\{[A-Za-z0-9-_]+\})?$c�v�d|vr|S|jdd�\}}||vr|Stj|�r|S|S)N�@�)�split� _PEP610_USER_PASS_ENV_VARS_REGEX�match)�netloc�safe_user_passwords�	user_pass�netloc_no_user_passs    r�_strip_auth_from_netlocrKSsL��
�&���
�%+�\�\�#�q�%9�"�I�"��'�'��
�'�-�-�i�8��
��rc��tjj|�}t|j|�}tjj|j||j|j|jf�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�urlsplitrKrG�
urlunsplit�scheme�path�query�fragment)�urlrH�
parsed_urlrGs    r�
_strip_urlrW^sl��
���&�&�s�+�J�
$�Z�%6�%6�8K�
L�F��<�<�"�"������O�O�������	
��rc�J�eZdZUdZdZded<ded<dd�					d
d�Zdd	�Zy)rz2Raised when when input data is not spec-compliant.N�
str | Noner2�str�messager1c���t|t�rJ|jr%|r|�d|j��n|j|_n||_|j|_y||_t	|�|_y)N�.)r4rr2r[rZ)�self�causer2s   r�__init__z!DirectUrlValidationError.__init__vs]���e�5�6��}�}�4;�w�i�q�����0������ '��� �=�=�D�L�"�D�L��u�:�D�Lrc�h�|jr|j�d|j��S|jS)Nz in )r2r[�r^s r�__str__z DirectUrlValidationError.__str__�s-���<�<��l�l�^�4����'7�8�8��|�|�r)r_zstr | Exceptionr2rYr#�None)r#rZ)r$r%r&�__doc__r2�__annotations__r`rcrrrrrps?��<��G�Z��
�L�#�	&��&��	&�

�&�$rrc� ��eZdZd�fd�Z�xZS)r:c�(��t�|�d|��y)NzMissing required valuer1)�superr`)r^r,�	__class__s  �rr`z#_DirectUrlRequiredKeyError.__init__�s���
���1�3��?r)r,rZr#rd)r$r%r&r`�
__classcell__)rjs@rr:r:�s���@�@rr:TF)�frozen�initc�^�eZdZUded<ded<dZded<dd�							d
d�Zedd	��Zy)rrZ�vcs�	commit_idNrY�requested_revision)rqc��tj|d|�tj|d|�tj|d|�y)Nrorprq��object�__setattr__)r^rorprqs    rr`zVcsInfo.__init__�s<��	���4���,����4��i�8����4�!5�7I�Jrc	�r�|t|td�t|td�t|td���S)Nrorqrp)rorqrp)r;rZr8rs  rr zVcsInfo._from_dict�s6����a��e�,�#�A�s�,@�A�#�A�s�K�8�
�	
r)rorZrprZrqrYr#rdr!)r$r%r&rfrqr`r'r rrrrr�sb��	�H��N�%)��
�)�*.�	K��	K��		K�
'�	K�
�
	K��
��
rrc�B�eZdZUdZded<dd�			dd�Zedd��Zy)	r
N�Mapping[str, str] | None�hashes�ryc�2�tj|d|�y)Nryrs)r^rys  rr`zArchiveInfo.__init__�s��
	���4��6�2rc�p�t|td�}|�-td�|j�D��s
t	dd���t|t
d�}|�[d|vr
t	dd���|j
dd�\}}|�||i}n.||vrt	d	|�d
�d���|||k7rt	d	|�d�d���||��S)
Nryc3�<K�|]}t|t����y�wr)r4rZ)�.0�hs  r�	<genexpr>z)ArchiveInfo._from_dict.<locals>.<genexpr>�s����)V��*�Q��*<�)V�s�zHash values must be stringsr1�hash�=z3Invalid hash format (expected '<algorithm>=<hash>')rCz
Algorithm z2 used in hash field is not present in hashes fieldz7 used in hash field has different value in hashes fieldrz)r8r�all�valuesrrZrD)rrry�legacy_hash�hash_algorithm�
hash_values      rr zArchiveInfo._from_dict�s����a��(�+����c�)V�f�m�m�o�)V�&V�*�-�x��
��1�c�6�*���"��+�%�.�I�"���*5�):�):�3��)B�&�N�J��~�(�*�5��"��/�2�$�^�$6�79�:� (���
�.�)�Z�7�2�$�^�$6�7>�?� &���
�&�!�!r)ryrxr#rdr!)r$r%r&ryrfr`r'r rrrr
r
�s?��'+�F�$�+�
,0�3�)�3�
�	3��"��"rr
c�B�eZdZUdZded<dd�			dd�Zedd��Zy)	rN�bool | None�editable�r�c�2�tj|d|�y)Nr�rs)r^r�s  rr`zDirInfo.__init__�s��
	���4��X�6rc�2�|t|td���S)Nr�r�)r8�boolrs  rr zDirInfo._from_dict�s����!�T�:�.�
�	
r)r�r�r#rdr!)r$r%r&r�rfr`r'r rrrrr�s>�� �H�k� �
!%�7��7�
�	7��
��
rrc���eZdZUdZded<dZded<dZded<dZd	ed
<dZded<ddddd
�											dd�Z	e
dd��Ze
dd��Zdddd�							dd�Z
dd�Zy)rz"A class representing a direct URL.rZrUN�ArchiveInfo | None�archive_info�VcsInfo | None�vcs_info�DirInfo | None�dir_inforY�subdirectory)r�r�r�r�c���tj|d|�tj|d|�tj|d|�tj|d|�tj|d|�y)NrUr�r�r�r�rs)r^rUr�r�r�r�s      rr`zDirectUrl.__init__�s^��	���4���,����4���>����4��X�6����4��X�6����4���>rc��|t|td�t|td�t|td�t|t
d�t
|td���}t|j�t|j�zt|j�zdk7rtd��|j�(|jjd	�s
td
d���|S)NrUr�r�r�r�)rUr�r�r�r�rCz?Exactly one of vcs_info, archive_info, dir_info must be presentzfile://z3URL scheme must be file:// when dir_info is presentr1)r;rZr@r
rrr8r�r�r�r�rrU�
startswith)rr�
direct_urls   rr zDirectUrl._from_dicts�����a��e�,�$�Q��^�D� ��G�Z�8� ��G�Z�8��a��n�5�
�
�
��$�$�%��:�*�*�+�
,��:�&�&�'�
(��	�
+�Q��
����*�:�>�>�3L�3L�Y�3W�*�E���
�
�rc�$�|j|�S)z@Create and validate a DirectUrl instance from a JSON dictionary.)r rs  r�	from_dictzDirectUrl.from_dict s���~�~�a� � rFT)�git)�generate_legacy_hash�strip_user_passwordrHc�F�tj|t��}|rh|jr\|jjrFtt
|jjj���\}}|�d|��|dd<|rt|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�rU)
�dataclasses�asdictr.r�ry�next�iter�itemsrWrU)r^r�r�rH�resr�r�s       r�to_dictzDirectUrl.to_dict%s���&� � ��4F�G���D�$5�$5�$�:K�:K�:R�:R�)-�d�4�3D�3D�3K�3K�3Q�3Q�3S�.T�)U�&�N�J�-;�,<�A�j�\�*J�C����'��#�D�H�H�.A�B�C��J��
rc�B�|j|j��y)z�Validate the DirectUrl instance against the specification.

        Raises :class:`DirectUrlValidationError` if invalid.
        N)r�r�rbs r�validatezDirectUrl.validate@s��
	
���t�|�|�~�&r)rUrZr�r�r�r�r�r�r�rYr#rdr!)r�r�r�r�rH�Collection[str]r#r")r#rd)r$r%r&rerfr�r�r�r�r`r'r r�r�r�rrrrr�s���,�	�H�'+�L�$�+�#�H�n�#�#�H�n�#�#�L�*�#�,0�#'�#'�#'�
?��
?�)�	
?�
!�
?�!�

?�!�
?�
�
?�����0�!��!�&+�$(�/7��#��"�	�
-��
�
�6'rr)r#z	list[str])r+zlist[tuple[str, Any]]r#zdict[str, Any])rr"r7�type[_T]r,rZr#z	_T | None)rr"r7r�r,rZr#r)rr"r>ztype[_FromMappingProtocolT]r,rZr#z_FromMappingProtocolT | None)rGrZrHr�r#rZ)rUrZrHr�r#rZ)'�
__future__rr��re�urllib.parserM�collections.abcr�typingrrrr�sysr	�version_infor�typing_extensionsrrrrr(r.r8r;r@�compilerErKrWr=rr:�	dataclassrr
rrrrr�<module>r�s��"��	��#�8�8���*�
���7�"��*����
�T�]��;�8�;�
 � 7�?S�T��D�
��	>��	>�'B�	>�IL�	>�!�	>�$.�2�:�:�5�$� �
��$�y��<@�!9�@�
����d��/�
�
�0�
�4����d��/�*"�*"�0�*"�Z����d��/�
�
�0�
�"����d��/�V'�V'�0�V'r