
    lc                    ~    d Z ddlm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mZm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)Requirement
safe_extrasplit_sectionsrequirementr   returnstrc                    t          | dd          r
d| j        z   S g }| j        D ]\  }}|                    ||z              |r(dd                    t          |                    z   dz   S dS )zFReturn the version specifier for a requirement in PEP 345/566 fashion.urlNz @ z (,) )getattrr   specsappendjoinsorted)r
   requires_distopvers       .lib/python3.11/site-packages/wheel/metadata.pyrequires_to_requires_distr      s    {E4(( '{&&M$ ' 'CR#X&&&& chhvm44555;;r    requirements	list[str]Iterator[str]c              #     K   | D ]c}t          j        |          }t          |          }d                    t	          |j                            }|rd| d}|j        |z   |z   V  ddS )z=Yield Requires-Dist: strings for parsed requirements strings.r   []N)r   parser   r   r   extrasproject_name)r   reqparsed_requirementspecr$   s        r   convert_requirementsr)      s       > >(.s33();<<&!3!:;;<< 	#"]]]F -6=====> >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   :   Provides-Extra(z) and zextra == '%s'z ; Requires-DistN)itemssplitr   r)   )r*   extradepends	conditionnew_reqs        r   generate_requirementsr9   *   s       )..00 7 7w	%< 	3${{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          |          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.1r0   r2   zrequires.txtc                    | d         pdS )Nr   r    )xs    r   <lambda>z%pkginfo_to_metadata.<locals>.<lambda>X   s    QqTZUW r   )keyDescription
r   r/   )openr   r#   replace_headerospathr   existsreadr   r	   r9   r3   
splitlineslstriptextwrapdedentset_payload)r:   r;   headerspkg_inforequires_pathrequires_filerequiresparsed_requirementsr5   reqsrB   valuedescriptiondescription_linesdedented_descriptions                  r   pkginfo_to_metadatar[   H   se    
lW	-	-	- +88>>'**+ + + + + + + + + + + + + + + .666!"!GLL??M	w~~m$$ *-   	,M$))++H	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, %^H%=%=CWCWXXX. 	* 	*KE43UDMBB * *
U<x~~'7'77 *$)HSM* =)K $$]3>>@@#yy "!$++--		*;ABB*? @ @AA 
  
 	1222]#Os#   "A  AA5CCC)r
   r   r   r   )r   r   r   r   )r*   r+   r   r,   )r:   r   r;   r   r   r   )__doc__
__future__r   os.pathrG   rM   email.messager   email.parserr   typingr   pkg_resourcesr   r   r	   r   r)   r9   r[   r?   r   r   <module>rc      s     # " " " " "   ! ! ! ! ! !             A A A A A A A A A A   	> 	> 	> 	>7 7 7 7<% % % % % %r   