�
�S�g � � � d Z ddlmZ ddlZddlZddlZddlZddlZddl m
Z
ddlmZ ddl
mZmZmZmZ ddlmZ dd �Zej* dd
�� Zej/ e� dd�� Z dd�Zdd
�Zdd�Zdd�Zdd�Z dd�Zdd�Z y)z2
Tools for converting old- to new-style metadata.
� )�annotationsN)�Message)�Parser)� Generator�Iterable�Iterator�Literal� )�Requirementc �. � | xr | j d� S )N�#)�
startswith)�strs �~/build/snapcraft-certbot-29b1212f749eeba2f1dece1adfe9a83a/parts/certbot/install/lib/python3.12/site-packages/wheel/metadata.py� _nonblankr s � ��*�s�~�~�c�*�*�*� c �\ � t j j t t | � � 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 r r s � � �?�?�(�(��[�(�)C�D�Dr c �n � t t t t j | j � � � S �N)�filterr r r �strip�
splitlines)�texts r �_r ) s! � ��)�S����D�O�O�,=�>�?�?r c # � K � d}g }t | � D ]a }|j d� r=|j d� r |s|r||f�� |dd j � }g }�Et d|� �|j |� �c ||f�� y�w)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)�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 � t j dd| � 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_extrar2 I s! � �
�6�6�#�S�%�0�6�6�8�8r c �0 � t j 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. r/ )�names r � safe_namer6 Q s � � �6�6�"�C��.�.r c �� � | j rd| j z S g }| j D ]* }|j |j |j z � �, |rddj t
|� � z S y)zFReturn the version specifier for a requirement in PEP 345/566 fashion.z @ � �,� )�url� specifierr' |