File: //usr/local/lib/python3.7/site-packages/wheel/__pycache__/metadata.cpython-37.pyc
B
O��g� � @ s� d Z ddlmZ ddlZddlZddlZddlZddlZddl m
Z
ddlmZ ddl
mZ ddlmZ d d
� Zejdd� �Ze�e�d
d� �Zdd� Zdd� Zdd� Zddd�dd�Zddd�dd�Zdd d!�d"d#�Zddd$d%�d&d'�ZdS )(z2
Tools for converting old- to new-style metadata.
� )�annotationsN)�Message)�Parser)�Iterator� )�Requirementc C s | o| � d� S )N�#)�
startswith)�str� r �2/tmp/pip-unpacked-wheel-f1gdtpe6/wheel/metadata.py� _nonblank s r
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)�iterabler r r r s r c C s t tttj| �� ��S )N)�filterr
r r
�strip�
splitlines)�textr r r �_( s r c c sz d}g }xbt | �D ]V}|�d�r^|�d�rR|s2|r<||fV |dd� �� }g }qhtd|��q|�|� qW ||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)�s�section�content�liner r r �split_sections- s
r# c 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)�extrar r r �
safe_extraF s r( c 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$ r% )�namer r r � safe_nameN s r+ r r
)�requirement�returnc C sZ t | dd�rd| j S g }x | jD ]}|�|j|j � q"W |rRdd�t|�� S dS dS )zFReturn the version specifier for a requirement in PEP 345/566 fashion.�urlNz @ � �,� )�getattrr. � specifierr �operator�version�join�sorted)r, Z
requires_dist�specr r r �requires_to_requires_distU s
r9 z list[str]z
Iterator[str])�requirementsr- c c s` xZ| D ]R}t |�}t|�}d�tdd� |jD ���}|rDd|� d�}t|j�| | V qW dS )z=Yield Requires-Dist: strings for parsed requirements strings.r0 c s s | ]}t |�V qd S )N)r( )�.0�er r r � <genexpr>i s z'convert_requirements.<locals>.<genexpr>r r N)r r9 r6 r7 �extrasr+ r* )r: �reqZparsed_requirementr8 r>