Your IP : 18.220.85.96


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/packaging/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/packaging/__pycache__/_parser.cpython-311.pyc

�

��bg�'��H�dZddlZddlmZmZmZmZmZmZddl	m
Z
mZGd�d��ZGd�d	e��Z
Gd
�de��ZGd�d
e��Zee
efZeeeefZeZeeZGd�de��Zdedefd�Zdedefd�Zdedeeeeeffd�Zdedededefd�Zdedeefd�Zdedeefd�Zdedefd�Zdedefd�Zdedefd�Zdedefd�Z dedefd�Z!dedefd �Z"dedefd!�Z#d"ede
fd#�Z$d$edefd%�Z%dedefd&�Z&dS)'z�Handwritten parser of dependency specifiers.

The docstring for each __parse_* function contains ENBF-inspired grammar representing
the implementation.
�N)�Any�List�
NamedTuple�Optional�Tuple�Union�)�
DEFAULT_RULES�	Tokenizerc�B�eZdZdeddfd�Zdefd�Zdefd�Zdefd�ZdS)�Node�value�returnNc��||_dS�N�r)�selfrs  �H/opt/cloudlinux/venv/lib64/python3.11/site-packages/packaging/_parser.py�__init__z
Node.__init__s
����
�
�
�c��|jSrr�rs r�__str__zNode.__str__s
���z�rc�(�d|jj�d|�d�S)N�<z('z')>)�	__class__�__name__rs r�__repr__z
Node.__repr__s ��7�4�>�*�7�7�d�7�7�7�7rc��t�r)�NotImplementedErrorrs r�	serializezNode.serializes��!�!r)r�
__module__�__qualname__�strrrrr!�rrr
r

s��������c��d�����������8�#�8�8�8�8�"�3�"�"�"�"�"�"rr
c��eZdZdefd�ZdS)�Variablerc� �t|��Sr�r$rs rr!zVariable.serialize����4�y�y�rN�rr"r#r$r!r%rrr'r'�/�������3������rr'c��eZdZdefd�ZdS)�Valuerc��d|�d�S)N�"r%rs rr!zValue.serialize!s���4�{�{�{�rNr+r%rrr.r. s/�������3������rr.c��eZdZdefd�ZdS)�Oprc� �t|��Srr)rs rr!zOp.serialize&r*rNr+r%rrr2r2%r,rr2c�Z�eZdZUeed<eed<eeed<eed<eeed<dS)�ParsedRequirement�name�url�extras�	specifier�markerN)rr"r#r$�__annotations__rr�
MarkerListr%rrr5r54sN�������

�I�I�I�	�H�H�H���I�����N�N�N��Z� � � � � � rr5�sourcerc�H�tt|t�����S�N)�rules)�_parse_requirementrr
�r=s r�parse_requirementrC?s���i��m�D�D�D�E�E�Er�	tokenizerc�T�|�d��|�dd���}|j}|�d��t|��}|�d��t	|��\}}}|�dd���t|||||��S)zI
    requirement = WS? IDENTIFIER WS? extras WS? requirement_details
    �WS�
IDENTIFIERz1package name at the start of dependency specifier��expected�ENDzend of dependency specifier)�consume�expect�text�
_parse_extras�_parse_requirement_detailsr5)rD�
name_tokenr6r8r7r9r:s       rrArACs������d�����!�!��R�"���J��?�D�
���d����
�9�
%�
%�F�
���d����7�	�B�B��C��F�
���U�%B��C�C�C��T�3��	�6�B�B�Brc�X�d}d}d}|�d��r�|���|�d��|j}|�dd���j}|�dd	�
��r|||fS|�dd���|�dd	�
��r|||fSt
||d�
��}n]|j}t|��}|�d��|�dd	�
��r|||fSt
|||rdnd�
��}|||fS)z~
    requirement_details = AT URL (WS requirement_marker?)?
                        | specifier WS? (requirement_marker)?
    �N�ATrF�URLzURL after @rHrJT��peekzwhitespace after URLzURL and whitespace)�
span_start�after�version specifierz#name and no valid version specifier)�check�readrK�positionrLrM�_parse_requirement_marker�_parse_specifier)rDr9r7r:�	url_start�specifier_starts      rrOrOXs~���I�
�C�
�F����t���"
����������$�����&�	����u�}��=�=�B���?�?�5�t�?�,�,�	,���F�+�+�����(>��?�?�?��?�?�5�t�?�,�,�	,���F�+�+�*��)�3G�
�
�
���$�,��$�Y�/�/�	����$�����?�?�5�t�?�,�,�	,���F�+�+�*��&��;�#�#�:�

�
�
��
��F�#�#rrWrXc���|�d��s|�d|�d�|���|���t|��}|�d��|S)z3
    requirement_marker = SEMICOLON marker WS?
    �	SEMICOLONz!Expected end or semicolon (after �))rWrF)rZ�raise_syntax_errorr[�
_parse_markerrK)rDrWrXr:s    rr]r]�s~���?�?�;�'�'�
��$�$�8��8�8�8�!�	%�	
�	
�	
��N�N����
�9�
%�
%�F�
���d�����Mrc�
�|�dd���sgS|�ddd���5|�d��t|��}|�d��ddd��n#1swxYwY|S)	zG
    extras = (LEFT_BRACKET wsp* extras_list? wsp* RIGHT_BRACKET)?
    �LEFT_BRACKETTrU�
RIGHT_BRACKETr8��aroundrFN)rZ�enclosing_tokensrK�_parse_extras_list)rDr8s  rrNrN�s����?�?�>��?�5�5���	�	�	#�	#����
$�
�
� � �
	���$����#�I�.�.�����$���� � � � � � � � � � � ���� � � � ��Ms�:A8�8A<�?A<c��g}|�d��s|S|�|���j��	|�d��|�dd���r|�d��n|�d��sn[|���|�d��|�dd���}|�|j����|S)	z>
    extras_list = identifier (wsp* ',' wsp* identifier)*
    rGTrFrUz"Expected comma between extra names�COMMAzextra name after commarH)rZ�appendr[rMrKrdrL)rDr8�extra_tokens   rrlrl�s����F��?�?�<�(�(���
�
�M�M�)�.�.�"�"�'�(�(�(�(����$�����?�?�<�d�?�3�3�	��(�(�)M�N�N�N�N�����)�)�	�����������$�����&�&�|�>V�&�W�W���
�
�k�&�'�'�'�(��Mrc���|�ddd���5|�d��t|��}|�d��ddd��n#1swxYwY|S)zr
    specifier = LEFT_PARENTHESIS WS? version_many WS? RIGHT_PARENTHESIS
              | WS? version_many WS?
    �LEFT_PARENTHESIS�RIGHT_PARENTHESISrYrirFN)rkrK�_parse_version_many)rD�parsed_specifierss  rr^r^�s���

�	#�	#���"�
$�
�
� � �
	���$����/�	�:�:�����$���� � � � � � � � � � � ���� � � � ��s�:A�A#�&A#c�2�d}|�d��r�|j}||���jz
}|�dd���r |�d||jdz���|�d	d���r|�d
||j���|�d��|�d��snF||���jz
}|�d��|�d����|S)
z@
    version_many = (SPECIFIER (WS? COMMA WS? SPECIFIER)*)?
    rR�	SPECIFIER�VERSION_PREFIX_TRAILTrUz6.* suffix can only be used with `==` or `!=` operatorsr	)rW�span_end�VERSION_LOCAL_LABEL_TRAILz@Local version label can only be used with `==` or `!=` operatorsrFrn)rZr\r[rMrdrK)rDrurWs   rrtrt�s@����
�/�/�+�
&�
&� ��'�
��Y�^�^�-�-�2�2���?�?�1��?�=�=�	��(�(�H�%�"�+�a�/�
)�
�
�
�
�?�?�6�T�?�B�B�	��(�(�R�%�"�+�
)�
�
�
�
	���$�������w�'�'�	���Y�^�^�-�-�2�2�����$����'�/�/�+�
&�
&� �*�rc�H�tt|t�����Sr?)rerr
rBs r�parse_markerr|�s����6��?�?�?�@�@�@rc��t|��g}|�d��rT|���}t|��}|�|j|f��|�d���T|S)z4
    marker = marker_atom (BOOLOP marker_atom)+
    �BOOLOP)�_parse_marker_atomrZr[�extendrM)rD�
expression�token�
expr_rights    rreres}��%�Y�/�/�0�J�
�/�/�(�
#�
#�4���� � ��'�	�2�2�
����5�:�z�2�3�3�3��/�/�(�
#�
#�4��rc�z�|�d��|�dd���rj|�ddd���5|�d��t|��}|�d��ddd��n#1swxYwYnt	|��}|�d��|S)	zw
    marker_atom = WS? LEFT_PARENTHESIS WS? marker WS? RIGHT_PARENTHESIS WS?
                | WS? marker_item WS?
    rFrrTrUrszmarker expressionriN)rKrZrkre�_parse_marker_item)rDr:s  rrrs
�����d�������)���5�5�
/�
�
'�
'���&�(�
�
�	$�	$�

���d�#�#�#�!.�y�!9�!9�F����d�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$��$�I�.�.��
���d�����Ms�:B�B�Bc��|�d��t|��}|�d��t|��}|�d��t|��}|�d��|||fS)zG
    marker_item = WS? marker_var WS? marker_op WS? marker_var WS?
    rF)rK�_parse_marker_var�_parse_marker_op)rD�marker_var_left�	marker_op�marker_var_rights    rr�r�$s������d����'�	�2�2�O�
���d���� ��+�+�I�
���d����(��3�3��
���d�����Y�(8�9�9rc�F�|�d��r:t|���j�dd����S|�d��r&t|���j��S|�d���dS)z/
    marker_var = VARIABLE | QUOTED_STRING
    �VARIABLE�.�_�
QUOTED_STRINGz+Expected a marker variable or quoted string)�messageN)rZ�process_env_varr[rM�replace�process_python_strrd�rDs rr�r�2s������z�"�"�
��y�~�~�/�/�4�<�<�S�#�F�F�G�G�G�	����	)�	)�
�!�)�.�.�"2�"2�"7�8�8�8��$�$�A�	%�	
�	
�	
�	
�	
r�env_varc�V�|dks|dkrtd��St|��S)N�platform_python_implementation�python_implementation)r')r�s rr�r�@s7���3�3�3��-�-�-��8�9�9�9��� � � r�
python_strc�b�tj|��}tt|����Sr)�ast�literal_evalr.r$)r�rs  rr�r�Js&����Z�(�(�E���U�����rc���|�d��r#|���td��S|�d��rQ|���|�dd���|�dd���td��S|�d	��r&t|���j��S|�d
��S)z&
    marker_op = IN | NOT IN | OP
    �IN�in�NOTrFzwhitespace after 'not'rHz'in' after 'not'znot in�OPzJExpected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in)rZr[r2rLrMrdr�s rr�r�Os������t���
��������$�x�x��	����	�	�
�����������(@��A�A�A�����(:��;�;�;��(�|�|��	����	�	�
��)�.�.�"�"�'�(�(�(��+�+�
8�
�
�	
r)'�__doc__r��typingrrrrrr�
_tokenizerr
rr
r'r.r2�	MarkerVar�
MarkerItem�
MarkerAtomr<r5r$rCrArO�intr]rNrlr^rtr|rerr�r�r�r�r�r%rr�<module>r�s������
�
�
�@�@�@�@�@�@�@�@�@�@�@�@�@�@�@�@�0�0�0�0�0�0�0�0�"�"�"�"�"�"�"�"������t����
�����D����
���������

�(�E�/�"�	�
�9�b�)�+�
,�
�
�
�
�#�Y�
�!�!�!�!�!�
�!�!�!�F�c�F�&7�F�F�F�F�C�)�C�0A�C�C�C�C�*0$��0$�
�3��X�j�)�)�*�0$�0$�0$�0$�f���),��58�������(�Y��4��9�����&�)���S�	�����6�	��c�����"�9�������@A��A��A�A�A�A�	�Y�	�:�	�	�	�	��)��
�����,:�)�:�
�:�:�:�:�
��
�y�
�
�
�
�!�S�!�X�!�!�!�!��3��5�����

�	�
�b�
�
�
�
�
�
r

?>