Current File : //proc/self/root/lib/python3/dist-packages/wheel/__pycache__/metadata.cpython-312.pyc
�

C�e����dZddlmZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZddlmZd	�Zej$d
��Zej)e�d��Zd�Zd
�Zd�Zdd�Zdd�Z				dd�Zdd�Zy)z2
Tools for converting old- to new-style metadata.
�)�annotationsN)�Message)�Parser)�Iterator�)�Requirementc�.�|xr|jd�S)N�#)�
startswith)�strs �0/usr/lib/python3/dist-packages/wheel/metadata.py�	_nonblankrs���*�s�~�~�c�*�*�*�c�\�tjjtt|��S)a�
    Yield valid lines of a string or iterable.
    >>> list(yield_lines(''))
    []
    >>> list(yield_lines(['foo', 'bar']))
    ['foo', 'bar']
    >>> list(yield_lines('foo\nbar'))
    ['foo', 'bar']
    >>> list(yield_lines('\nfoo\n#bar\nbaz #comment'))
    ['foo', 'baz #comment']
    >>> list(yield_lines(['foo\nbar', 'baz', 'bing\n\n\n']))
    ['foo', 'bar', 'baz', 'bing']
    )�	itertools�chain�
from_iterable�map�yield_lines)�iterables r
rrs ���?�?�(�(��[�(�)C�D�Drc�n�ttttj|j���S�N)�filterrrr�strip�
splitlines)�texts r
�_r(s!���)�S����D�O�O�,=�>�?�?rc#�K�d}g}t|�D]a}|jd�r=|jd�r |s|r||f��|ddj�}g}�Et	d|��|j|��c||f��y�w)arSplit a string or iterable thereof into (section, content) pairs
    Each ``section`` is a stripped version of the section header ("[section]")
    and each ``content`` is a list of stripped lines excluding blank lines and
    comment-only lines.  If there are any such lines before the first section
    header, they're returned in a first ``section`` of ``None``.
    N�[�]r���zInvalid section heading)rr�endswithr�
ValueError�append)�s�section�content�lines    r
�split_sectionsr)-s������G��G��A��
!���?�?�3���}�}�S�!��g�!�7�*�*��q��*�*�*�,���� �!:�D�A�A��N�N�4� �
!��7�
��s�A;A=c�L�tjdd|�j�S)z�Convert an arbitrary string to a standard 'extra' name
    Any runs of non-alphanumeric characters are replaced with a single '_',
    and the result is always lowercased.
    z[^A-Za-z0-9.-]+r)�re�sub�lower)�extras r
�
safe_extrar/Fs!��
�6�6�#�S�%�0�6�6�8�8rc�0�tjdd|�S)z�Convert an arbitrary string to a standard distribution name
    Any runs of non-alphanumeric/. characters are replaced with a single '-'.
    z[^A-Za-z0-9.]+�-)r+r,)�names r
�	safe_namer3Ns���6�6�"�C��.�.rc���t|dd�rd|jzSg}|jD]*}|j|j|j
z��,|rddj
t|��zSy)zFReturn the version specifier for a requirement in PEP 345/566 fashion.�urlNz @ � �,�)�getattrr5�	specifierr$�operator�version�join�sorted)�requirement�
requires_dist�specs   r
�requires_to_requires_distrBUss���{�E�4�(��{���&�&��M��%�%�;�����T�]�]�T�\�\�9�:�;���S�X�X�f�]�3�4�4�4�rc#��K�|D]h}t|�}t|�}djtd�|jD���}|rd|�d�}t|j�|z|z���jy�w)z=Yield Requires-Dist: strings for parsed requirements strings.r7c3�2K�|]}t|����y�wr)r/)�.0�es  r
�	<genexpr>z'convert_requirements.<locals>.<genexpr>is���� R�1��A�� R�s�rr N)rrBr=r>�extrasr3r2)�requirements�req�parsed_requirementrArHs     r
�convert_requirementsrLdsy�����A��(��-��(�);�<�����&� R�8J�8Q�8Q� R�R�S�������]�F��*�/�/�0�6�9�D�@�@�A�s�A/A1c#�K�|j�D]k\}}d}|xsd}d|vr|jdd�\}}t|�}|rd|f��|rd|zdz}|d|zz
}|rd|z}t|�D]}d	||zf���
�my
�w)a,
    Convert requirements from a setup()-style dictionary to
    ('Requires-Dist', 'requirement') and ('Provides-Extra', 'extra') tuples.

    extras_require is a dictionary of {extra: [requirements]} as passed to setup(),
    using the empty extra {'': [requirements]} to hold install_requires.
    r8�:r�Provides-Extra�(z) and z
extra == '%s'z ; �
Requires-DistN)�items�splitr/rL)�extras_requirer.�depends�	condition�new_reqs     r
�generate_requirementsrXps�����)�.�.�0�7���w��	������%�<�$�{�{�3��2��E�9��5�!���"�E�)�)���)�O�h�6�	���5�0�0�I���	�)�I�+�G�4�	7�G�!�7�Y�#6�6�6�	7�!7�s�BBc
� �t|d��5}t�j|�}ddd�jdd�|d=|d=tj
j
|d�}tj
j|�rvt|d��5}|j�}ddd�tt�d	��
�}|D]4\}}	t||	i�D]\}
}|
|f|j�vs�|||
<�!�6|d}|rq|dj�}
dj
|
d
j�tj dj
|
dd��df�}|j#|�|d=|S#1swY��QxYw#1swY��xYw)zN
    Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
    zutf-8)�encodingNzMetadata-Versionz2.1rOrQzrequires.txtc��|dxsdS)Nrr8�)�xs r
�<lambda>z%pkginfo_to_metadata.<locals>.<lambda>�s��Q�q�T�Z�UW�r)�key�Description�
rr)�openr�parse�replace_header�os�pathr=�exists�readr>r)rXrRr�lstrip�textwrap�dedent�set_payload)�
egg_info_path�pkginfo_path�headers�pkg_info�
requires_path�
requires_file�requires�parsed_requirementsr.�reqsr_�value�description�description_lines�dedented_descriptions               r
�pkginfo_to_metadatarz�s���
�l�W�	-�+���8�>�>�'�*��+�
���.��6��!�"���!��G�G�L�L���?�M�	�w�w�~�~�m�$�
�-�'�
2�	,�m�$�)�)�+�H�	,�%�^�H�%=�CW�X��.�	*�K�E�4�3�U�D�M�B�
*�
��U���<�x�~�~�'7�7�$)�H�S�M�
*�	*�
�=�)�K��$�]�3�>�>�@��#�y�y�"�!�$�+�+�-�����	�	�*;�A�B�*?� @�A��
� 
��	���1�2��]�#��O�C+�+��	,�	,�s�E7�F�7F�F
)r?r�returnr)rIz	list[str]r{z
Iterator[str])rTzdict[str, list[str]]r{zIterator[tuple[str, str]])rmrrnrr{r)�__doc__�
__future__r�	functoolsr�os.pathrer+rj�
email.messager�email.parserr�typingr�vendored.packaging.requirementsrr�singledispatchr�registerrrr)r/r3rBrLrXrzr\rr
�<module>r�s����#����	��!���8�+����E��E�"
���c��@��@��29�/��	A�7�(�7��7�<%r