
    m&ph                    2   S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSK	J
r
  SSKJr  SSKJrJrJrJr  SSKJr  SS	 jr\R*                  SS
 j5       r\R/                  \5      SS j5       r    SS jrSS jrSS jrSS jrSS jr    SS jrSS jr g)z2
Tools for converting old- to new-style metadata.
    )annotationsN)Message)Parser)	GeneratorIterableIteratorLiteral   )Requirementc                @    U =(       a    U R                  S5      (       + $ )N#)
startswith)strs    A/var/www/html/venv/lib/python3.13/site-packages/wheel/metadata.py	_nonblankr      s    *s~~c***    c                \    [         R                  R                  [        [        U 5      5      $ )aQ  
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    [        [        [        [        R                  U R                  5       5      5      $ N)filterr   r   r   strip
splitlines)texts    r   _r    )   s!    )SDOO,=>??r   c              #  (  #    Sn/ n[        U 5       Hv  nUR                  S5      (       aL  UR                  S5      (       a*  U(       d  U(       a  X4v   USS R                  5       n/ nMY  [	        SU5      eUR                  U5        Mx     X4v   g7f)a^  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!!g!**q***, !:DAANN4   
s   BBc                N    [         R                  " SSU 5      R                  5       $ )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_extrar2   I   s!    
 66#S%06688r   c                2    [         R                  " SSU 5      $ )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_namer6   Q   s     66"C..r   c                   U R                   (       a  SU R                   -   $ / nU R                   H+  nUR                  UR                  UR                  -   5        M-     U(       a  SSR                  [        U5      5      -   $ g)zFReturn the version specifier for a requirement in PEP 345/566 fashion.z @  , )url	specifierr'   operatorversionjoinsorted)requirementrequires_distspecs      r   requires_to_requires_distrD   X   si    {&&!M%%T]]T\\9: & SXXf]3444r   c              #     #    U  Hn  n[        U5      n[        U5      nSR                  [        S UR                   5       5      5      nU(       a  SU S3n[        UR                  5      U-   U-   v   Mp     g7f)z=Yield Requires-Dist: strings for parsed requirements strings.r9   c              3  8   #    U  H  n[        U5      v   M     g 7fr   )r2   ).0es     r   	<genexpr>'convert_requirements.<locals>.<genexpr>l   s      R8Q1A8Qs   r"   r#   N)r   rD   r?   r@   extrasr6   r5   )requirementsreqparsed_requirementrC   rK   s        r   convert_requirementsrO   g   sq     (-();<& R8J8Q8Q RRS]F*//069D@@ s   A6A8c              #  `  #    U R                  5        H  u  pSnU=(       d    SnSU;   a  UR                  SS5      u  p[        U5      nU(       a  SU4v   U(       a  SU-   S-   nUSU S3-  nU(       a  S	U-   n[        U5       H  n[	        [        XC-   5      5      nS
U4v   M!     M     g7f)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 == ''z ; Requires-DistN)itemssplitr2   rO   r   r   )extras_requirer1   depends	conditionnew_reqcanonical_reqs         r   generate_requirementsr]   s   s      )..0	%<${{32E5!"E)))Oh6	:eWA..I	)I+G4GG,? @AM!=00 5! 1s   B,B.c           
     <   [        USS9 n[        5       R                  U5      nSSS5        WR                  SS5        US	 US	 [        R
                  R                  U S5      n[        R
                  R                  U5      (       ar  [        USS9 nUR                  5       nSSS5        [        [        W5      S	 S
9nU H5  u  p[        X05       H   u  pX4UR                  5       ;  d  M  XU
'   M"     M7     US   nU(       ar  US   R                  5       nSR                  US   R                  5       [        R                   " SR                  USS 5      5      S45      nUR#                  U5        US	 U$ ! , (       d  f       GN]= f! , (       d  f       N= f)zF
Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
zutf-8)encodingNzMetadata-Versionz2.1rR   rU   zrequires.txtc                    U S   =(       d    S$ )Nr   r:    )xs    r   <lambda>%pkginfo_to_metadata.<locals>.<lambda>   s    QqTZUWZr   )keyDescription
r   r
   )openr   parsereplace_headerospathr?   existsreadr@   r,   r]   rV   r   lstriptextwrapdedentset_payload)egg_info_pathpkginfo_pathheaderspkg_inforequires_pathrequires_filerequiresparsed_requirementsr1   reqsre   valuedescriptiondescription_linesdedented_descriptions                  r   pkginfo_to_metadatar      sw    
lW	-8>>'* 
. .6!"!GGLL?M	ww~~m$$-'2m$))+H 3 %^H%=CWX.KE3UMB
<x~~'77$)SM C /
 =)K$]3>>@#yy "!$++-		*;AB*? @A 
 	12]#OC 
.	- 32s   E;F;
F

F)r   r   returnzbool | Literal[''])r   zIterable[str]r   Iterator[str])r   r   r   r   )r(   zstr | Iterator[str]r   z3Generator[tuple[str | None, list[str]], None, None])r1   r   r   r   )r5   r   r   r   )rA   r   r   r   )rL   z	list[str]r   r   )rX   zdict[str | None, list[str]]r   zIterator[tuple[str, str]])rs   r   rt   r   r   r   )!__doc__
__future__r   	functoolsr   os.pathrk   r.   rp   email.messager   email.parserr   typingr   r   r   r	   vendored.packaging.requirementsr   r   singledispatchr   registerr   r    r,   r2   r6   rD   rO   r]   r   ra   r   r   <module>r      s    #    	  !  9 9 8+ E E" c@ @869/	A1/11>%r   