
    Yh                       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j/                  e      dd       Z	 	 	 	 ddZddZddZddZddZ	 	 	 	 ddZddZ y)z2
Tools for converting old- to new-style metadata.
    )annotationsN)Message)Parser)	GeneratorIterableIteratorLiteral   )Requirementc                .    | xr | j                  d       S )N#)
startswith)strs    _/var/www/django-portfolio.reubendavern.link/venv/lib/python3.12/site-packages/wheel/metadata.py	_nonblankr      s    *s~~c***    c                \    t         j                  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DDr   c                n    t        t        t        t        j                  | j                                     S N)filterr   r   r   strip
splitlines)texts    r   _r    )   s!    )SDOO,=>??r   c              #     K   d}g }t        |       D ]a  }|j                  d      r=|j                  d      r |s|r||f |dd j                         }g }Et	        d|      |j                  |       c ||f yw)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!g!7**q***, !:DAANN4 
! 7
s   A;A=c                L    t        j                  dd|       j                         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_extrar2   I   s!    
 66#S%06688r   c                0    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_namer6   Q   s     66"C..r   c                    | j                   rd| j                   z   S g }| j                  D ]*  }|j                  |j                  |j                  z          , |rddj                  t        |            z   S y)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   sn    {&&!M%% ;T]]T\\9:; SXXf]3444r   c              #     K   | D ]h  }t        |      }t        |      }dj                  t        d |j                  D                    }|rd| d}t        |j                        |z   |z    j yw)z=Yield Requires-Dist: strings for parsed requirements strings.r9   c              3  2   K   | ]  }t        |        y wr   )r2   ).0es     r   	<genexpr>z'convert_requirements.<locals>.<genexpr>l   s      R1A Rs   r"   r#   N)r   rD   r?   r@   extrasr6   r5   )requirementsreqparsed_requirementrC   rJ   s        r   convert_requirementsrN   g   sy      A(-();<& R8J8Q8Q RRS]F*//069D@@As   A/A1c              #  2  K   | j                         D ]  \  }}d}|xs d}d|v r|j                  dd      \  }}t        |      }|rd|f |rd|z   dz   }|d| dz  }|rd	|z   }t        |      D ]  }t	        t        ||z               }d
|f !  yw)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   rN   r   r   )extras_requirer1   depends	conditionnew_reqcanonical_reqs         r   generate_requirementsr\   s   s      )..0 1w	%<${{32E95!"E)))Oh6	:eWA..I	)I+G4 	1GGi,? @AM!=00	1!1s   BBc           
         t        |d      5 }t               j                  |      }ddd       j                  dd       |d= |d= t        j
                  j                  | d      }t        j
                  j                  |      rvt        |d      5 }|j                         }ddd       t        t              d	 
      }|D ]4  \  }}	t        ||	i      D ]  \  }
}|
|f|j                         vs|||
<   ! 6 |d   }|rq|d   j                         }dj                  |d   j                         t        j                   dj                  |dd             df      }|j#                  |       |d= |S # 1 sw Y   QxY w# 1 sw Y   xY w)zN
    Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
    zutf-8)encodingNzMetadata-Versionz2.1rQ   rT   zrequires.txtc                    | d   xs 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\   rU   r   lstriptextwrapdedentset_payload)egg_info_pathpkginfo_pathheaderspkg_inforequires_pathrequires_filerequiresparsed_requirementsr1   reqsrc   valuedescriptiondescription_linesdedented_descriptions                  r   pkginfo_to_metadatar~      s    
lW	- +8>>'*+ .6!"!GGLL?M	ww~~m$-'2 	,m$))+H	, %^H%=CWX. 	*KE43UDMB *
U<x~~'77$)HSM*	*
 =)K$]3>>@#yy "!$++-		*;AB*? @A 
 	12]#OC+ +	, 	,s   E7F7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   )rK   z	list[str]r   r   )rW   zdict[str | None, list[str]]r   zIterator[tuple[str, str]])rq   r   rr   r   r   r   )!__doc__
__future__r   	functoolsr   os.pathri   r.   rn   email.messager   email.parserr   typingr   r   r   r	   vendored.packaging.requirementsr   r   singledispatchr   registerr   r    r,   r2   r6   rD   rN   r\   r~   r`   r   r   <module>r      s    #    	  !  9 9 8+ E E" c@ @869/	A1/11>%r   