o
    g¹«jJP  ã                	   @  s  U 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mZmZmZmZmZ ddlmZmZmZmZmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZ erad dlm Z  g d¢Z!dXdd„Z"ee#ee#e	e# f ge$f Z%ed Z&	 ddhZ'h d£Z(G dd„ de)ƒZ*G dd„ de)ƒZ+G dd„ de,ƒZ-G dd„ deƒZ.dYdd „Z/dZd#d$„Z0	%d[d\d+d,„Z1d-d.„ d/d.„ d0d.„ ej2ej2ej3ej2d1d.„ d2œZ4d3e5d4< d]d<d=„Z6d^d?d@„Z7d_dCdD„Z8d`dFdG„Z9dadJdK„Z:ej;dbdLdM„ƒZ<dbdNdO„Z=G dPdQ„ dQƒZ>dcdSdT„Z?dddVdW„Z@dS )eé    )ÚannotationsN)ÚSet)ÚTYPE_CHECKINGÚCallableÚLiteralÚ	TypedDictÚUnionÚcasté   )Ú
MarkerAtomÚ
MarkerListÚOpÚValueÚVariable)Úparse_marker)ÚParserSyntaxError)ÚInvalidSpecifierÚ	Specifier©Úcanonicalize_name)ÚMapping)ÚEnvironmentÚEvaluateContextÚInvalidMarkerÚMarkerÚUndefinedComparisonÚUndefinedEnvironmentNameÚdefault_environmentÚreturnú	list[str]c                   C  s   t S ©N)Ú__all__© r"   r"   úQ/var/www/html/laksyashrimp/venv/lib/python3.10/site-packages/packaging/markers.pyÚ__dir__#   s   r$   )ÚmetadataÚ	lock_fileÚrequirementÚextrasÚdependency_groups>   Úpython_versionÚplatform_releaseÚpython_full_versionÚimplementation_versionc                   @  ó   e Zd ZdZdS )r   zëRaised when attempting to create a :class:`Marker` from invalid input.

    This error indicates that the given marker string does not conform to the
    :ref:`specification of dependency specifiers <pypug:dependency-specifiers>`.
    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r"   r"   r"   r#   r   =   ó    r   c                   @  r.   )r   zçRaised when evaluating an unsupported marker comparison.

    This can happen when marker values are compared as versions but do not
    conform to the :ref:`specification of version specifiers
    <pypug:version-specifiers>`.
    Nr/   r"   r"   r"   r#   r   E   r4   r   c                   @  r.   )r   aÍ  Raised when evaluating a marker that references a missing environment key.

    Subclasses :class:`KeyError` so that code catching the bare ``KeyError`` that
    a missing environment lookup historically produced keeps working.

    .. versionchanged:: 26.3
        Now subclasses :class:`KeyError` (was :class:`ValueError`) and is raised by
        :meth:`Marker.evaluate` for missing environment keys, where a bare
        ``KeyError`` was raised before.
    Nr/   r"   r"   r"   r#   r   N   r4   r   c                   @  s~   e Zd ZU dZded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded< 	 ded	< 	 ded
< 	 ded< 	 ded< 	 ded< dS )r   z„
    A dictionary that represents a Python environment as captured by
    :func:`default_environment`. All fields are required.
    ÚstrÚimplementation_namer-   Úos_nameÚplatform_machiner+   Úplatform_systemÚplatform_versionr,   Úplatform_python_implementationr*   Úsys_platformN)r0   r1   r2   r3   Ú__annotations__r"   r"   r"   r#   r   [   s0   
 r   ÚresultúMarkerList | MarkerAtom | strc                 C  sÊ   t | tƒrdd„ | D ƒS t | tƒs| S | \}}}t |tƒr1|jdkr1t |tƒr1t|jƒ}t|ƒ}n/t |tƒrJ|jdkrJt |tƒrJt|jƒ}t|ƒ}nt |tƒr`|jtv r`t |tƒr`tt|jƒƒ}|||fS )Nc                 S  ó   g | ]}t |ƒ‘qS r"   ©Ú_normalize_extras©Ú.0Úrr"   r"   r#   Ú
<listcomp>¬   ó    z%_normalize_extras.<locals>.<listcomp>Úextra)Ú
isinstanceÚlistÚtupler   Úvaluer   r   ÚMARKERS_ALLOWING_SET)r>   ÚlhsÚopÚrhsÚnormalized_extrar"   r"   r#   rB   ¨   s$   






ÿ
ÿ	
rB   Úresultsr   c                 C  s   dd„ | D ƒS )z!
    Normalize extra values.
    c                 S  r@   r"   rA   rC   r"   r"   r#   rF   Ë   rG   z+_normalize_extra_values.<locals>.<listcomp>r"   )rR   r"   r"   r#   Ú_normalize_extra_valuesÆ   s   rS   TÚmarkerúlist[str] | MarkerAtom | strÚfirstúbool | Noner5   c                 C  s¦   t | tttfƒs
J ‚t | tƒr&t| ƒdkr&t | d ttfƒr&t| d |d�S t | tƒrBdd„ | D ƒ}|r9d |¡S dd |¡ d S t | tƒrQd d	d
„ | D ƒ¡S | S )Nr
   r   ©rV   c                 s  s   � | ]	}t |d d�V  qdS )FrX   N)Ú_format_marker©rD   Úmr"   r"   r#   Ú	<genexpr>Ý   s   € z!_format_marker.<locals>.<genexpr>ú ú(ú)c                 S  s   g | ]}|  ¡ ‘qS r"   )Ú	serializerZ   r"   r"   r#   rF   ã   rG   z"_format_marker.<locals>.<listcomp>)rI   rJ   rK   r5   ÚlenrY   Újoin)rT   rV   Úinnerr"   r"   r#   rY   Î   s   ÿÿ


rY   c                 C  s   | |v S r    r"   ©rN   rP   r"   r"   r#   Ú<lambda>é   ó    re   c                 C  s   | |vS r    r"   rd   r"   r"   r#   re   ê   rf   c                 C  ó   dS ©NFr"   ©Ú_lhsÚ_rhsr"   r"   r#   re   ë   ó    c                 C  rg   rh   r"   ri   r"   r"   r#   re   ð   rl   )Úinznot inú<z<=z==z!=z>=ú>zdict[str, Operator]Ú
_operatorsrN   rO   r   rP   ústr | AbstractSet[str]ÚkeyÚboolc                C  s~   |  ¡ }|tv r#z
t|› |› �ƒ}W n	 ty   Y nw |j| dd�S t |¡}|d u r:td|›d| ›d|›d�ƒ‚|| |ƒS )NT)Úprereleasesz
Undefined z on z and Ú.)r`   ÚMARKERS_REQUIRING_VERSIONr   r   Úcontainsrp   Úgetr   )rN   rO   rP   rr   Úop_strÚspecÚoperr"   r"   r#   Ú_eval_opô   s   ÿ

r|   ú"tuple[str, str | AbstractSet[str]]c                 C  sb   |dkrt |tƒsJ dƒ‚| |fS |tv r-t |tƒr"t| ƒt|ƒfS t| ƒdd„ |D ƒfS | |fS )NrH   zextra value must be a stringc                 S  s   h | ]}t |ƒ’qS r"   r   )rD   Úvr"   r"   r#   Ú	<setcomp>  rG   z_normalize.<locals>.<setcomp>)rI   r5   rM   r   )rN   rP   rr   r"   r"   r#   Ú
_normalize  s   
r€   Úenvironmentú!dict[str, str | AbstractSet[str]]c                 C  s$   z| | W S  t y   t|ƒd ‚w r    )ÚKeyErrorr   )r�   rr   r"   r"   r#   Ú_lookup_environment  s
   

ÿr„   Úmarkersc           
   	   C  s  g g}| D ]y}t |tƒr|d  t||ƒ¡ qt |tƒri|\}}}t |tƒr2|j}t||ƒ}|j}	n|j}|j}t||ƒ}	t |tƒsRt	d|›d|› d| 
¡ ›d�ƒ‚t||	|d�\}}	|d  t|||	|d�¡ q|dkrs| g ¡ q|dkrxqtd	|›�ƒ‚td
d„ |D ƒƒS )NéÿÿÿÿzSet-valued marker z= can only be used with the membership form (e.g. "<name>" in z-); it cannot appear on the left-hand side of ru   )rr   ÚorÚandzUnexpected marker c                 s  s   � | ]}t |ƒV  qd S r    )Úall)rD   Úitemr"   r"   r#   r\   G  s   € z$_evaluate_markers.<locals>.<genexpr>)rI   rJ   ÚappendÚ_evaluate_markersrK   r   rL   r„   r5   r   r`   r€   r|   Ú	TypeErrorÚany)
r…   r�   ÚgroupsrT   rN   rO   rP   Úenvironment_keyÚ	lhs_valueÚ	rhs_valuer"   r"   r#   rŒ   #  s:   






þýÿrŒ   Úinfoúsys._version_infoc                 C  sB   | j › d| j› d| j› �}| j}|dkr||d t| jƒ 7 }|S )Nru   Úfinalr   )ÚmajorÚminorÚmicroÚreleaselevelr5   Úserial)r“   ÚversionÚkindr"   r"   r#   Ú_format_full_versionJ  s
   r�   c                  C  s^   t tjjƒ} tjj}|| tjt ¡ t ¡ t 	¡ t ¡ t 
¡ t ¡ d t ¡ dd… ¡tjdœS )aV  Build the default marker environment for the current Python process.

    The values are derived from process-constant data (the running interpreter
    and the host platform), so this is cached and built only once. The result is
    shared between callers and must never be mutated; :func:`default_environment`
    returns a fresh copy.
    ru   Né   )r6   r-   r7   r8   r+   r9   r:   r,   r;   r*   r<   )r�   ÚsysÚimplementationr›   ÚnameÚosÚplatformÚmachineÚreleaseÚsystemr*   Úpython_implementationrb   Úpython_version_tuple)Úiverr6   r"   r"   r#   Ú_cached_default_environmentR  s   	õrª   c                   C  s   t dttƒ ƒƒS )ay  Return the default marker environment for the current Python process.

    This is the base environment used by :meth:`Marker.evaluate`. A fresh copy
    is returned on every call so callers may freely mutate the result; a shallow
    copy suffices because all values are immutable strings.

    .. versionchanged:: 26.3
        The environment is computed once per process and cached, since it is
        derived from process-constant data. Patching ``platform``/``sys``/``os``
        after the first call has no effect; pass an explicit ``environment`` to
        :meth:`Marker.evaluate` to evaluate against different values.
    r   )r	   Údictrª   r"   r"   r"   r#   r   l  s   r   c                   @  sŒ   e Zd ZdZdZd*dd„Zed+dd„ƒZd,dd„Zd,dd„Z	d-dd„Z
d.dd„Zd,dd„Zd/dd„Zd0dd„Zd0d d!„Z	"	#d1d2d(d)„Zd"S )3r   aê  Represents a parsed dependency marker expression.

    Marker expressions are parsed according to the
    :ref:`specification of dependency specifiers <pypug:dependency-specifiers>`.

    :param marker: The string representation of a marker expression.
    :raises InvalidMarker: If ``marker`` cannot be parsed.

    Instances are safe to serialize with :mod:`pickle`. They use a stable
    format so the same pickle can be loaded in future packaging releases.

    .. versionchanged:: 26.2

        Added a stable pickle format. Pickles created with packaging 26.2+ can
        be unpickled with future releases.  Backward compatibility with pickles
        from packaging < 26.2 is supported but may be removed in a future
        release.
    )Ú_markersrT   r5   r   ÚNonec              
   C  sB   g | _ z
tt|ƒƒ| _ W d S  ty  } ztt|ƒƒ|‚d }~ww r    )r¬   rS   Ú_parse_markerr   r   r5   )ÚselfrT   Úer"   r"   r#   Ú__init__’  s   €ÿzMarker.__init__r…   r   c                 C  s   |   | ¡}||_|S )z’Create a Marker instance from a pre-parsed marker tree.

        This avoids re-parsing serialised marker strings when combining markers.
        )Ú__new__r¬   )Úclsr…   Únewr"   r"   r#   Ú_from_markers°  s   
zMarker._from_markersc                 C  s
   t | jƒS r    )rY   r¬   ©r¯   r"   r"   r#   Ú__str__º  s   
zMarker.__str__c                 C  s   d| j j› dt| ƒ›d�S )Nrn   r^   z)>)Ú	__class__r0   r5   r¶   r"   r"   r#   Ú__repr__½  s   zMarker.__repr__Úintc                 C  s   t t| ƒƒS r    )Úhashr5   r¶   r"   r"   r#   Ú__hash__À  s   zMarker.__hash__ÚotherÚobjectrs   c                 C  s   t |tƒstS t| ƒt|ƒkS r    )rI   r   ÚNotImplementedr5   ©r¯   r½   r"   r"   r#   Ú__eq__Ã  s   
zMarker.__eq__c                 C  s   t | ƒS r    )r5   r¶   r"   r"   r#   Ú__getstate__É  s   zMarker.__getstate__Ústatec              
   C  sÐ   t |tƒr$z
tt|ƒƒ| _W d S  ty# } ztd|›�ƒ|‚d }~ww t |tƒr;d|v r;|d }t |tƒr;|| _d S t |t	ƒrat
|ƒdkra|\}}t |tƒrad|v ra|d }t |tƒra|| _d S td|›�ƒ‚)NzCannot restore Marker from r¬   rž   )rI   r5   rS   r®   r¬   r   r�   r«   rJ   rK   ra   )r¯   rÃ   Úexcr…   Ú_Ú	slot_dictr"   r"   r#   Ú__setstate__Î  s*   
þ€ÿ

zMarker.__setstate__c                 C  ó"   t |tƒstS |  | jd|jg¡S )zXCombine this marker with another using ``and``.

        .. versionadded:: 26.1
        rˆ   ©rI   r   r¿   rµ   r¬   rÀ   r"   r"   r#   Ú__and__æ  ó   
zMarker.__and__c                 C  rÈ   )zWCombine this marker with another using ``or``.

        .. versionadded:: 26.1
        r‡   rÉ   rÀ   r"   r"   r#   Ú__or__ï  rË   zMarker.__or__Nr%   r�   ú+Mapping[str, str | AbstractSet[str]] | NoneÚcontextr   c                 C  s‚   t dtƒ ƒ}|dkr|tƒ tƒ dœO }n|dkrd|d< |dur9||O }d|v r9t d|d ƒ}|r5t|ƒnd|d< t| jt|ƒƒS )	a¶  Evaluate a marker.

        Return the boolean from evaluating this marker against the environment.
        The environment is determined from the current Python process unless
        passed in explicitly.

        :param environment: Mapping containing keys and values to override the
           detected environment.
        :param EvaluateContext context: The context in which the marker is
            evaluated, which influences what marker names are considered valid.
            Accepted values are ``"metadata"`` (for core metadata; default),
            ``"lock_file"``, and ``"requirement"`` (i.e. all other situations).
        :raises UndefinedComparison: If the marker uses a comparison on values
            that are not valid versions per the :ref:`specification of version
            specifiers <pypug:version-specifiers>`.
        :raises UndefinedEnvironmentName: If the marker references a value that
            is missing from the evaluation environment.
        :returns: ``True`` if the marker matches, otherwise ``False``.

        .. versionchanged:: 25.0
            Added the ``context`` parameter, which influences which marker names
            are considered valid.
        r‚   r&   )r(   r)   r%   Ú rH   Nz
str | None)r	   r   Ú	frozensetr   rŒ   r¬   Ú_repair_python_full_version)r¯   r�   rÎ   Úcurrent_environmentrH   r"   r"   r#   Úevaluateø  s$   ÿ
þ
ÿzMarker.evaluate)rT   r5   r   r­   )r…   r   r   r   )r   r5   )r   rº   )r½   r¾   r   rs   )rÃ   r¾   r   r­   )r½   r   r   r   )Nr%   )r�   rÍ   rÎ   r   r   rs   )r0   r1   r2   r3   Ú	__slots__r±   Úclassmethodrµ   r·   r¹   r¼   rÁ   rÂ   rÇ   rÊ   rÌ   rÓ   r"   r"   r"   r#   r   |  s"    

	






	ýr   r,   c                 C  s   |   d¡r
| › d�S | S )úƒ
    Work around platform.python_version() returning something that is not PEP 440
    compliant for non-tagged Python builds.
    ú+Úlocal)Úendswith)r,   r"   r"   r#   Ú_pep440_python_full_version-  s   

rÚ   Úenvc                 C  s   t d| d ƒ}t|ƒ| d< | S )rÖ   r5   r,   )r	   rÚ   )rÛ   r,   r"   r"   r#   rÑ   7  s   rÑ   )r   r   )r>   r?   r   r?   )rR   r   r   r   )T)rT   rU   rV   rW   r   r5   )
rN   r5   rO   r   rP   rq   rr   r5   r   rs   )rN   r5   rP   rq   rr   r5   r   r}   )r�   r‚   rr   r5   r   rq   )r…   r   r�   r‚   r   rs   )r“   r”   r   r5   )r   r   )r,   r5   r   r5   )rÛ   r‚   r   r‚   )AÚ
__future__r   Ú	functoolsÚoperatorr¢   r£   rŸ   Úcollections.abcr   ÚAbstractSetÚtypingr   r   r   r   r   r	   Ú_parserr   r   r   r   r   r   r®   Ú
_tokenizerr   Ú
specifiersr   r   Úutilsr   r   r!   r$   r5   rs   ÚOperatorr   rM   rv   Ú
ValueErrorr   r   rƒ   r   r   rB   rS   rY   ÚeqÚnerp   r=   r|   r€   r„   rŒ   r�   Úcacherª   r   r   rÚ   rÑ   r"   r"   r"   r#   Ú<module>   sf    
	
M
	ÿø



	
'
 
2
