
    ϶vg                       d Z ddlmZ ddlZddlZddlZddlZddlZddl	m
Z
 ddlmZ ddlmZ ddlmZ d	 Zej        d
             Ze                    e          d             Zd Zd Zd Zd dZd!dZd"dZd#dZdS )$z2
Tools for converting old- to new-style metadata.
    )annotationsN)Message)Parser)Iterator   )Requirementc                2    | o|                      d           S )N#)
startswith)strs    ^/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/setuptools/_vendor/wheel/metadata.py	_nonblankr      s    *s~~c****    c                f    t           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)CDDDr   c                    t          t          t          t          j        |                                                     S N)filterr   r   r   strip
splitlines)texts    r   _r   )   s(    )SDOO,=,=>>???r   c              #  2  K   d}g }t          |           D ]z}|                    d          rN|                    d          r)|s|r||fV  |dd                                         }g }Ut	          d|          |                    |           {||fV  dS )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   zInvalid section heading)r   r   endswithr   
ValueErrorappend)ssectioncontentlines       r   split_sectionsr)   .   s       GGA 
! 
!??3 		!}}S!! B +g +!7****qt***,, !:DAAANN4     7
r   c                R    t          j        dd|                                           S )zConvert 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/   G   s%    
 6#S%0066888r   c                .    t          j        dd|           S )zConvert 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_namer3   O   s     6"C...r   requirementr   returnr   c                    t          | dd          r
d| j        z   S g }| j        D ]$}|                    |j        |j        z              %|r%dd                    t          |                    z   S dS )zFReturn the version specifier for a requirement in PEP 345/566 fashion.urlNz @  , )getattrr7   	specifierr$   operatorversionjoinsorted)r4   requires_distspecs      r   requires_to_requires_distrC   V   s    {E4(( '{&&M% ; ;T]T\9:::: SXXf]334444rr   requirements	list[str]Iterator[str]c              #     K   | D ]u}t          |          }t          |          }d                    t          d |j        D                                 }|rd| d}t          |j                  |z   |z   V  vdS )z=Yield Requires-Dist: strings for parsed requirements strings.r9   c              3  4   K   | ]}t          |          V  d S r   )r/   ).0es     r   	<genexpr>z'convert_requirements.<locals>.<genexpr>j   s(       R R1A R R R R R Rr   r   r    N)r   rC   r?   r@   extrasr3   r2   )rD   reqparsed_requirementrB   rL   s        r   convert_requirementsrO   e   s       A A(--();<<& R R8J8Q R R RRRSS 	#"]]]F*/0069D@@@@@A Ar   extras_requiredict[str, list[str]]Iterator[tuple[str, str]]c              #    K   |                                  D ]s\  }}d}|pd}d|v r|                    dd          \  }}t          |          }|rd|fV  |rd|z   dz   }|d|z  z  }|rd|z   }t          |          D ]}d	||z   fV  td
S )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.
    r:   :r   Provides-Extra(z) and zextra == '%s'z ; Requires-DistN)itemssplitr/   rO   )rP   r.   depends	conditionnew_reqs        r   generate_requirementsr]   q   s       )..00 7 7w	%<<${{322E95!! 	1"E)))) 7)Oh6	500I 	*	)I+G44 	7 	7G!7Y#666666	7!7 7r   egg_info_pathpkginfo_pathr   c           
        t          |d          5 }t                                          |          }ddd           n# 1 swxY w Y   |                    dd           |d= |d= t          j                            | d          }t          j                            |          rt          |d          5 }|                                }ddd           n# 1 swxY w Y   t          t          |          d	 
          }|D ]9\  }}	t          ||	i          D ]"\  }
}|
|f|                                vr|||
<   #:|d         }|r|d                                         }d                    |d                                         t          j        d                    |dd                             df          }|                    |           |d= |S )zN
    Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
    zutf-8)encodingNzMetadata-Versionz2.1rU   rW   zrequires.txtc                    | d         pdS )Nr   r:    )xs    r   <lambda>z%pkginfo_to_metadata.<locals>.<lambda>   s    QqTZUW r   )keyDescription
r   r   )openr   parsereplace_headerospathr?   existsreadr@   r)   r]   rX   r   lstriptextwrapdedentset_payload)r^   r_   headerspkg_inforequires_pathrequires_filerequiresparsed_requirementsr.   reqsrf   valuedescriptiondescription_linesdedented_descriptions                  r   pkginfo_to_metadatar      sh    
lW	-	-	- +88>>'**+ + + + + + + + + + + + + + + .666!"!GLL??M	w~~m$$ *-'222 	,m$))++H	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, %^H%=%=CWCWXXX. 	* 	*KE43UDMBB * *
U<x~~'7'777$)HSM* =)K $$]3>>@@#yy "!$++--		*;ABB*? @ @AA 
  
 	1222]#Os#   "A  AA7CCC)r4   r   r5   r   )rD   rE   r5   rF   )rP   rQ   r5   rR   )r^   r   r_   r   r5   r   )__doc__
__future__r   	functoolsr   os.pathrl   r+   rq   email.messager   email.parserr   typingr   vendored.packaging.requirementsr   r   singledispatchr   registerr   r   r)   r/   r3   rC   rO   r]   r   rc   r   r   <module>r      s    # " " " " "          				  ! ! ! ! ! !             8 8 8 8 8 8+ + + E E E" c@ @ @  29 9 9/ / /   	A 	A 	A 	A7 7 7 7<% % % % % %r   