a
    ç´«jJP  ã                	   @  sh  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rÂd dlm Z  g d¢Z!ddœd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.dddœdd „Z/d!d!d"œd#d$„Z0dUd&d'd(d)œd*d+„Z1d,d-„ d.d-„ d/d-„ ej2ej2ej3ej2d0d-„ d1œZ4d2e5d3< d(d4d5d(d6d7œd8d9„Z6d(d5d(d:d;œd<d=„Z7d>d(d5d?œd@dA„Z8d!d>d6dBœdCdD„Z9dEd(dFœdGdH„Z:ej;ddœdIdJ„ƒZ<ddœdKdL„Z=G dMdN„ dNƒZ>d(d(dOœdPdQ„Z?d>d>dRœdSdT„Z@dS )Vé    )Ú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_environmentz	list[str]©Úreturnc                   C  s   t S ©N)Ú__all__© r"   r"   úP/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/packaging/markers.pyÚ__dir__#   s    r$   )ÚmetadataÚ	lock_fileÚrequirementÚextrasÚdependency_groups>   Úplatform_releaseÚpython_full_versionÚimplementation_versionÚpython_versionc                   @  s   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   =   s   r   c                   @  s   e Zd ZdZdS )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   s   r   c                   @  s   e Zd ZdZdS )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   s   r   c                   @  sj   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)r/   r0   r1   r2   Ú__annotations__r"   r"   r"   r#   r   [   s   
r   zMarkerList | MarkerAtom | str)Úresultr   c                 C  sÊ   t | tƒrdd„ | D ƒS t | tƒs&| S | \}}}t |tƒrb|jdkrbt |tƒrbt|jƒ}t|ƒ}n^t |tƒr”|jdkr”t |tƒr”t|jƒ}t|ƒ}n,t |tƒrÀ|jtv rÀt |tƒrÀtt|jƒƒ}|||fS )Nc                 S  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ÚrhsZnormalized_extrar"   r"   r#   r>   ¨   s&    






ÿþýr>   r   )Úresultsr   c                 C  s   dd„ | D ƒS )z!
    Normalize extra values.
    c                 S  s   g | ]}t |ƒ‘qS r"   r=   r?   r"   r"   r#   rB   Ë   rC   z+_normalize_extra_values.<locals>.<listcomp>r"   )rM   r"   r"   r#   Ú_normalize_extra_valuesÆ   s    rN   Tzlist[str] | MarkerAtom | strzbool | Noner3   )ÚmarkerÚfirstr   c                 C  s¬   t | tttfƒsJ ‚t | tƒrLt| ƒdkrLt | d ttfƒrLt| d |d�S t | tƒr†dd„ | D ƒ}|rrd |¡S dd |¡ d S n"t | tƒr¤d d	d
„ | D ƒ¡S | S d S )Nr
   r   ©rP   c                 s  s   | ]}t |d d�V  qdS )FrQ   N)Ú_format_marker©r@   Úmr"   r"   r#   Ú	<genexpr>Ý   rC   z!_format_marker.<locals>.<genexpr>ú ú(ú)c                 S  s   g | ]}|  ¡ ‘qS r"   )Ú	serializerS   r"   r"   r#   rB   ã   rC   z"_format_marker.<locals>.<listcomp>)rE   rF   rG   r3   ÚlenrR   Újoin)rO   rP   Úinnerr"   r"   r#   rR   Î   s     ÿ
þý


rR   c                 C  s   | |v S r    r"   ©rJ   rL   r"   r"   r#   Ú<lambda>é   rC   r^   c                 C  s   | |vS r    r"   r]   r"   r"   r#   r^   ê   rC   c                 C  s   dS ©NFr"   ©Z_lhsZ_rhsr"   r"   r#   r^   ë   rC   c                 C  s   dS r_   r"   r`   r"   r"   r#   r^   ð   rC   )Úinznot inú<z<=z==z!=z>=ú>zdict[str, Operator]Ú
_operatorsr   zstr | AbstractSet[str]Úbool)rJ   rK   rL   Úkeyr   c                C  s~   |  ¡ }|tv rFzt|› |› �ƒ}W n ty6   Y n0 |j| dd�S t |¡}|d u rttd|›d| ›d|›d�ƒ‚|| |ƒS )NT)Úprereleasesz
Undefined z on z and Ú.)rY   ÚMARKERS_REQUIRING_VERSIONr   r   Úcontainsrd   Úgetr   )rJ   rK   rL   rf   Zop_strÚspecÚoperr"   r"   r#   Ú_eval_opô   s    
rn   z"tuple[str, str | AbstractSet[str]])rJ   rL   rf   r   c                 C  sb   |dkr"t |tƒsJ dƒ‚| |fS |tv rZt |tƒrDt| ƒt|ƒfS t| ƒdd„ |D ƒfS | |fS )NrD   zextra value must be a stringc                 S  s   h | ]}t |ƒ’qS r"   r   )r@   Úvr"   r"   r#   Ú	<setcomp>  rC   z_normalize.<locals>.<setcomp>)rE   r3   rI   r   )rJ   rL   rf   r"   r"   r#   Ú
_normalize  s    
rq   ú!dict[str, str | AbstractSet[str]])Úenvironmentrf   r   c                 C  s,   z
| | W S  t y&   t|ƒd ‚Y n0 d S r    )ÚKeyErrorr   )rs   rf   r"   r"   r#   Ú_lookup_environment  s    
ru   )Úmarkersrs   r   c           
   	   C  s  g g}| D ]ô}t |tƒr.|d  t||ƒ¡ q
t |tƒrÒ|\}}}t |tƒrd|j}t||ƒ}|j}	n|j}|j}t||ƒ}	t |tƒs¤t	d|›d|› d| 
¡ ›d�ƒ‚t||	|d�\}}	|d  t|||	|d�¡ q
|dkræ| g ¡ q
|dkrðq
td	|›�ƒ‚q
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 rh   )rf   ÚorÚandzUnexpected marker c                 s  s   | ]}t |ƒV  qd S r    )Úall)r@   Úitemr"   r"   r#   rU   G  rC   z$_evaluate_markers.<locals>.<genexpr>)rE   rF   ÚappendÚ_evaluate_markersrG   r   rH   ru   r3   r   rY   rq   rn   Ú	TypeErrorÚany)
rv   rs   ÚgroupsrO   rJ   rK   rL   Zenvironment_keyÚ	lhs_valueÚ	rhs_valuer"   r"   r#   r}   #  s:    






þýÿr}   zsys._version_info)Úinfor   c                 C  sB   | j › d| j› d| j› �}| j}|dkr>||d t| jƒ 7 }|S )Nrh   Úfinalr   )ÚmajorÚminorÚmicroÚreleaselevelr3   Ú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.
    rh   Né   )r4   r,   r5   r6   r*   r7   r8   r+   r9   r-   r:   )rŒ   ÚsysÚimplementationrŠ   ÚnameÚosÚplatformÚmachineÚreleaseÚsystemr-   Úpython_implementationr[   Úpython_version_tuple)Úiverr4   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œdd„Zedd d	œd
d„ƒZddœdd„Zddœdd„Z	ddœdd„Z
dddœdd„Zddœdd„Zdddœdd„Zd d dœdd„Zd d dœd d!„Zd)d$d%dd&œd'd(„Zd"S )*r   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.
    )Ú_markersr3   ÚNone)rO   r   c              
   C  sP   g | _ ztt|ƒƒ| _ W n2 tyJ } ztt|ƒƒ|‚W Y d }~n
d }~0 0 d S r    )r›   rN   Ú_parse_markerr   r   r3   )ÚselfrO   Úer"   r"   r#   Ú__init__’  s
    zMarker.__init__r   )rv   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›   )Úclsrv   Únewr"   r"   r#   Ú_from_markers°  s    
zMarker._from_markersr   c                 C  s
   t | jƒS r    )rR   r›   ©rž   r"   r"   r#   Ú__str__º  s    zMarker.__str__c                 C  s   d| j j› dt| ƒ›d�S )Nrb   rW   z)>)Ú	__class__r/   r3   r¥   r"   r"   r#   Ú__repr__½  s    zMarker.__repr__Úintc                 C  s   t t| ƒƒS r    )Úhashr3   r¥   r"   r"   r#   Ú__hash__À  s    zMarker.__hash__Úobjectre   )Úotherr   c                 C  s   t |tƒstS t| ƒt|ƒkS r    )rE   r   ÚNotImplementedr3   ©rž   r­   r"   r"   r#   Ú__eq__Ã  s    
zMarker.__eq__c                 C  s   t | ƒS r    )r3   r¥   r"   r"   r#   Ú__getstate__É  s    zMarker.__getstate__)Ústater   c              
   C  sâ   t |tƒrVztt|ƒƒ| _W n4 tyP } ztd|›�ƒ|‚W Y d }~n
d }~0 0 d S t |tƒr„d|v r„|d }t |tƒr„|| _d S t |t	ƒrÐt
|ƒdkrÐ|\}}t |tƒrÐd|v rÐ|d }t |tƒrÐ|| _d S td|›�ƒ‚d S )NzCannot restore Marker from r›   r�   )rE   r3   rN   r�   r›   r   r~   rš   rF   rG   rZ   )rž   r²   Úexcrv   Ú_Z	slot_dictr"   r"   r#   Ú__setstate__Î  s&    
&

zMarker.__setstate__c                 C  s"   t |tƒstS |  | jd|jg¡S )zXCombine this marker with another using ``and``.

        .. versionadded:: 26.1
        ry   ©rE   r   r®   r¤   r›   r¯   r"   r"   r#   Ú__and__æ  s    
zMarker.__and__c                 C  s"   t |tƒstS |  | jd|jg¡S )zWCombine this marker with another using ``or``.

        .. versionadded:: 26.1
        rx   r¶   r¯   r"   r"   r#   Ú__or__ï  s    
zMarker.__or__Nr%   z+Mapping[str, str | AbstractSet[str]] | Noner   )rs   Úcontextr   c                 C  s‚   t dtƒ ƒ}|dkr(|tƒ tƒ dœO }n|dkr8d|d< |durr||O }d|v rrt d|d ƒ}|rjt|ƒ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.
        rr   r&   )r(   r)   r%   Ú rD   Nz
str | None)r	   r   Ú	frozensetr   r}   r›   Ú_repair_python_full_version)rž   rs   r¹   Úcurrent_environmentrD   r"   r"   r#   Úevaluateø  s$    ÿþ

ÿzMarker.evaluate)Nr%   )r/   r0   r1   r2   Ú	__slots__r    Úclassmethodr¤   r¦   r¨   r«   r°   r±   rµ   r·   r¸   r¾   r"   r"   r"   r#   r   |  s    		  ýr   )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Å   )Úenvr   c                 C  s   t d| d ƒ}t|ƒ| d< | S )rÁ   r3   r+   )r	   rÅ   )rÆ   r+   r"   r"   r#   r¼   7  s    r¼   )T)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$   r3   re   ÚOperatorr   rI   ri   Ú
ValueErrorr   r   rt   r   r   r>   rN   rR   ÚeqÚnerd   r;   rn   rq   ru   r}   rŒ   Úcacher™   r   r   rÅ   r¼   r"   r"   r"   r#   Ú<module>   sb    	M	 ÿø	' 2
