File: //proc/self/root/usr/local/lib/python3.10/dist-packages/wheel/__pycache__/metadata.cpython-310.pyc
o
��h � @ s� d Z ddlmZ ddlZddlZddlZddlZddlZddl m
Z
ddlmZ ddl
mZmZmZmZ ddlmZ d3dd
�Zejd4dd��Ze�e�d5dd��Zd6dd�Zd7dd�Zd8dd �Zd9d#d$�Zd:d'd(�Zd;d,d-�Zd<d1d2�Z dS )=z2
Tools for converting old- to new-style metadata.
� )�annotationsN)�Message)�Parser)� Generator�Iterable�Iterator�Literal� )�Requirement�str�return�bool | Literal['']c C s | o| � d� S )N�#)�
startswith)r � r �9/usr/local/lib/python3.10/dist-packages/wheel/metadata.py� _nonblank s r �iterable�
Iterable[str]�
Iterator[str]c C s t j�tt| ��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)r r r r r s r �textc C s t tttj| �� ��S �N)�filterr r r �strip�
splitlines)r r r r �_) s r �s�str | Iterator[str]�3Generator[tuple[str | None, list[str]], None, None]c c sv � d}g }t | �D ]*}|�d�r.|�d�r)|s|r||fV |dd� �� }g }q td|��|�|� q ||fV dS )ar Split 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)r r �endswithr �
ValueError�append)r! �section�content�liner r r �split_sections. s �
r- �extrac C s t �dd| ��� 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)r. r r r �
safe_extraI s r2 �namec C s t �dd| �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/ r0 )r3 r r r � safe_nameQ s r5 �requirementr
c C sL | j rd| j S g }| jD ]}|�|j|j � q
|r$dd�t|�� S dS )zFReturn the version specifier for a requirement in PEP 345/566 fashion.z @ � �,� )�url� specifierr) �operator�version�join�sorted)r6 �
requires_dist�specr r r �requires_to_requires_distX s
rB �requirements� list[str]c c s^ � | D ])}t |�}t|�}d�tdd� |jD ���}|r"d|� d�}t|j�| | V qdS )z=Yield Requires-Dist: strings for parsed requirements strings.r8 c s s � | ]}t |�V qd S r )r2 )�.0�er r r � <genexpr>l s � z'convert_requirements.<locals>.<genexpr>r$ r% N)r
rB r>