
    S$g                       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mZmZmZ ddlmZ d)dZej        d*d            Ze                    e          d+d            Zd,dZd-dZd.dZd/dZd0d Zd1d$Zd2d(Z dS )3z2
Tools for converting old- to new-style metadata.
    )annotationsN)Message)Parser)	GeneratorIterableIteratorLiteral   )Requirementstrreturnbool | Literal['']c                2    | o|                      d           S )N#)
startswith)r   s    N/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/wheel/metadata.py	_nonblankr      s    *s~~c****    iterableIterable[str]Iterator[str]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)r   s    r   r   r      s$     ?(([()C)CDDDr   textc                    t          t          t          t          j        |                                                     S N)filterr   r   r   strip
splitlines)r   s    r   _r$   )   s(    )SDOO,=,=>>???r   sstr | Iterator[str]3Generator[tuple[str | None, list[str]], None, None]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)r%   sectioncontentlines       r   split_sectionsr2   .   s       GGA 
! 
!??3 		!}}S!! B +g +!7****qt***,, !:DAAANN4     7
r   extrac                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)r3   s    r   
safe_extrar8   I   s%    
 6#S%0066888r   namec                .    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.]+-)r5   r6   )r9   s    r   	safe_namer<   Q   s     6"C...r   requirementr   c                    | j         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.z @  , )url	specifierr.   operatorversionjoinsorted)r=   requires_distspecs      r   requires_to_requires_distrJ   X   s|     '{&&!M% ; ;T]T\9:::: SXXf]334444rr   requirements	list[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.r@   c              3  4   K   | ]}t          |          V  d S r    )r8   ).0es     r   	<genexpr>z'convert_requirements.<locals>.<genexpr>l   s(       R R1A R R R R R Rr   r)   r*   N)r   rJ   rF   rG   extrasr<   r9   )rK   reqparsed_requirementrI   rR   s        r   convert_requirementsrU   g   s       A A(--();<<& R R8J8Q R R RRRSS 	#"]]]F*/0069D@@@@@A Ar   extras_requiredict[str | None, list[str]]Iterator[tuple[str, str]]c              #  T  K   |                                  D ]\  }}d}|pd}d|v r|                    dd          \  }}t          |          }|rd|fV  |rd|z   dz   }|d| dz  }|rd	|z   }t          |          D ]'}t	          t          ||z                       }d
|fV  (d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.
    rA   :r
   Provides-Extra(z) and z
extra == ''z ; Requires-DistN)itemssplitr8   rU   r   r   )rV   r3   depends	conditionnew_reqcanonical_reqs         r   generate_requirementsre   s   s      )..00 1 1w	%<<${{322E95!! 	/"E)))) 7)Oh6	.e....I 	*	)I+G44 	1 	1GGi,? @ @AAM!=00000	1!1 1r   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.1r[   r^   zrequires.txtc                    | d         pdS )Nr   rA    )xs    r   <lambda>z%pkginfo_to_metadata.<locals>.<lambda>   s    QqTZUW r   )keyDescription
r   r
   )openr   parsereplace_headerospathrF   existsreadrG   r2   re   r_   r#   lstriptextwrapdedentset_payload)rf   rg   headerspkg_inforequires_pathrequires_filerequiresparsed_requirementsr3   reqsrn   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)r   r   r   r   )r   r   r   r   )r   r   r   r   )r%   r&   r   r'   )r3   r   r   r   )r9   r   r   r   )r=   r   r   r   )rK   rL   r   r   )rV   rW   r   rX   )rf   r   rg   r   r   r   )!__doc__
__future__r   	functoolsr   os.pathrt   r5   ry   email.messager   email.parserr   typingr   r   r   r	   vendored.packaging.requirementsr   r   singledispatchr   registerr   r$   r2   r8   r<   rJ   rU   re   r   rk   r   r   <module>r      s    # " " " " "          				  ! ! ! ! ! !       9 9 9 9 9 9 9 9 9 9 9 9 8 8 8 8 8 8+ + + + E E E E" c@ @ @ @   69 9 9 9/ / / /   	A 	A 	A 	A1 1 1 1>% % % % % %r   