o
    5‘ði<  ã                   @  sð  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Zddl	m
Z ejr3ddlZddlmZ e e¡ZdZe de d ejejB ¡ZdXdd„ZdZe de› d�ej¡ZdYdd„ZzzddlmZ W n eyw   ddl mZ Y nw dZdd„Z!W n ey‘   e "d¡ dZdd„Z!Y nw dZdd„Z#dZdd„Z$d[dd „Z%G d!d"„ d"ƒZ&zdd#l'm(Z) dZd$d%„Z*W n eyÁ   e&ƒ Z*Y nw dZd&d'„Z+dZd(d)„Z,d*Z-e de-› d�ej¡Z.d+Z/e de/› d�ej¡Z0d,Z1e de1› d�ej¡Z2dZd-d.„Z3dZd/d0„Z4dZd1d2„Z5dZd3d4„Z6dZd5d6„Z7dZd7d8„Z8dZd9d:„Z9d\d<d=„Z:d\d>d?„Z;d\d@dA„Z<d\dBdC„Z=d\dDdE„Z>d\dFdG„Z?d\dHdI„Z@d\dJdK„ZAd\dLdM„ZBd\dNdO„ZCzddPlmDZE dZdQdR„ZFW n e�yi   e "dS¡ dZdTdR„ZFY nw e dUej¡ZGdZdVdW„ZHdS )]a@  
The functions in this module are used to validate schemas with the
`format JSON Schema keyword
<https://json-schema.org/understanding-json-schema/reference/string#format>`_.

The correspondence is given by replacing the ``_`` character in the name of the
function with a ``-`` to obtain the format name and vice versa.
é    )ÚannotationsN)Úchain)ÚLiterala•  
    v?
    (?:
        (?:(?P<epoch>[0-9]+)!)?                           # epoch
        (?P<release>[0-9]+(?:\.[0-9]+)*)                  # release segment
        (?P<pre>                                          # pre-release
            [-_\.]?
            (?P<pre_l>alpha|a|beta|b|preview|pre|c|rc)
            [-_\.]?
            (?P<pre_n>[0-9]+)?
        )?
        (?P<post>                                         # post release
            (?:-(?P<post_n1>[0-9]+))
            |
            (?:
                [-_\.]?
                (?P<post_l>post|rev|r)
                [-_\.]?
                (?P<post_n2>[0-9]+)?
            )
        )?
        (?P<dev>                                          # dev release
            [-_\.]?
            (?P<dev_l>dev)
            [-_\.]?
            (?P<dev_n>[0-9]+)?
        )?
    )
    (?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))?       # local version
z^\s*z\s*$ÚversionÚstrÚreturnÚboolc                 C  ó   t  | ¡duS )zpSee :ref:`PyPA's version specification <pypa:version-specifiers>`
    (initially introduced in :pep:`440`).
    N)ÚVERSION_REGEXÚmatch)r   © r   úl/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/config/_validate_pyproject/formats.pyÚpep440B   ó   r   z'([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])ú^ú$Únamec                 C  r	   )zlSee :ref:`PyPA's name specification <pypa:name-format>`
    (initially introduced in :pep:`508#names`).
    N)ÚPEP508_IDENTIFIER_REGEXr   )r   r   r   r   Úpep508_identifierP   r   r   )ÚrequirementsÚvaluec                 C  ó(   zt  | ¡ W dS  t jy   Y dS w )z{See :ref:`PyPA's dependency specifiers <pypa:dependency-specifiers>`
        (initially introduced in :pep:`508`).
        FT)Ú_reqÚRequirementÚInvalidRequirement©r   r   r   r   Úpep508`   ó   þÿr   z¡Could not find an installation of `packaging`. Requirements, dependencies and versions might not be validated. To enforce validation, please install `packaging`.c                 C  ó   dS ©NTr   r   r   r   r   r   q   ó   c                   s(   t ‡ fdd„dD ƒƒrdS tdˆ › �ƒS )zÒExpression that can be used to specify/lock versions (including ranges)
    See ``versionspec`` in :ref:`PyPA's dependency specifiers
    <pypa:dependency-specifiers>` (initially introduced in :pep:`508`).
    c                 3  s   � | ]}|ˆ v V  qd S ©Nr   )Ú.0Úcr   r   r   Ú	<genexpr>z   ó   € z%pep508_versionspec.<locals>.<genexpr>)ú;ú]ú@FÚrequirement)Úanyr   r   r   r   r   Úpep508_versionspecu   s   r+   c                 C  sB   |   d¡\}}}dd„ t| d¡| d¡ƒD ƒ}tdd„ |D ƒƒS )zÂSee PyPA's specification for defining build-backend references
    introduced in :pep:`517#source-trees`.

    This is similar to an entry-point reference (e.g., ``package.module:object``).
    ú:c                 s  ó   � | ]}|  ¡ V  qd S r!   ©Ústrip©r"   Úir   r   r   r$   �   r%   z+pep517_backend_reference.<locals>.<genexpr>Ú.c                 s  s   � | ]	}|rt |ƒV  qd S r!   ©Úpython_identifierr0   r   r   r   r$   �   ó   € )Ú	partitionÚ_chainÚsplitÚall)r   ÚmoduleÚ_ÚobjÚidentifiersr   r   r   Úpep517_backend_referenceˆ   s    r>   c                  C  sˆ   dd l } ddlm} ddlm} d}|  ¡ }|||d��}|ƒ }| dd¡|d< | ¡  | 	d	d
¡¡W  d   ƒ S 1 s=w   Y  d S )Nr   )ÚMessage)Úurlopenz.https://pypi.org/pypi?:action=list_classifiers)Úcontextzcontent-typez
text/plainÚcontent_typeÚcharsetzutf-8)
ÚsslÚemail.messager?   Úurllib.requestr@   Úcreate_default_contextÚ	getheaderÚreadÚdecodeÚ	get_param)rD   r?   r@   ÚurlrA   ÚresponseÚheadersr   r   r   Ú_download_classifiers—   s   $ýrO   c                   @  s:   e Zd ZU dZded< 	 ddd„Zddd	„Zddd„ZdS )Ú_TroveClassifierak  The ``trove_classifiers`` package is the official way of validating classifiers,
    however this package might not be always available.
    As a workaround we can still download a list from PyPI.
    We also don't want to be over strict about it, so simply skipping silently is an
    option (classifiers will be validated anyway during the upload to PyPI).
    z None | Literal[False] | set[str]Ú
downloadedr   ÚNonec                 C  s   d | _ d| _d| _d S )NFÚtrove_classifier)rQ   Ú_skip_downloadÚ__name__©Úselfr   r   r   Ú__init__³   s   
z_TroveClassifier.__init__c                 C  s
   d| _ d S r   )rT   rV   r   r   r   Ú_disable_download¸   s   
z"_TroveClassifier._disable_downloadr   r   r   c                 C  s®   | j du s
| jdu rdS t d¡st d¡r"d| _ d}t |¡ dS | j d u rKd}t |¡ z
ttƒ  ¡ ƒ| _ W n t	yJ   d| _ t d¡ Y dS w || j v pV| 
¡  d¡S )	NFTÚ
NO_NETWORKÚVALIDATE_PYPROJECT_NO_NETWORKzxInstall ``trove-classifiers`` to ensure proper validation. Skipping download of classifiers list from PyPI (NO_NETWORK).zxInstall ``trove-classifiers`` to ensure proper validation. Meanwhile a list of classifiers will be downloaded from PyPI.z*Problem with download, skipping validationú
private ::)rQ   rT   ÚosÚgetenvÚ_loggerÚdebugÚsetrO   Ú
splitlinesÚ	ExceptionÚlowerÚ
startswith)rW   r   Úmsgr   r   r   Ú__call__¼   s(   ÿ

ÿ

ýz_TroveClassifier.__call__N)r   rR   ©r   r   r   r   )rU   Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__rX   rY   rg   r   r   r   r   rP   ¤   s   
 

rP   )Úclassifiersc                 C  s   | t v p
|  ¡  d¡S )z!See https://pypi.org/classifiers/r\   )Ú_trove_classifiersrd   re   r   r   r   r   rS   Ü   s   rS   c                 C  s>   |   d¡^}}| d¡sdS td |dtdƒ … g|¢¡ƒS )z—Name of a directory containing type stubs.
    It must follow the name scheme ``<package>-stubs`` as defined in
    :pep:`561#stub-only-packages`.
    r2   ú-stubsFN)r8   ÚendswithÚpython_module_nameÚjoinÚlen)r   ÚtopÚchildrenr   r   r   Úpep561_stub_nameè   s   
"rv   c                 C  sr   ddl m} z(|| ƒ}|js&t d| › �¡ |  d¡s&d| v s&|d| › �ƒ}t|jo,|jƒW S  ty8   Y dS w )z§Valid URL (validation uses :obj:`urllib.parse`).
    For maximum compatibility please make sure to include a ``scheme`` prefix
    in your URL (e.g. ``http://``).
    r   )ÚurlparsezsFor maximum compatibility please make sure to include a `scheme` prefix in your URL (e.g. 'http://'). Given value: )ú/ú\r(   zhttp://F)	Úurllib.parserw   Úschemer_   Úwarningre   r   Únetlocrc   )r   rw   Úpartsr   r   r   rL   ÷   s   þÿÿrL   z[^\[\s=]([^=]*[^\s=])?z[\w.-]+z\w+(\.\w+)*c                 C  s   |   ¡ S )zXCan be used as identifier in Python.
    (Validation uses :obj:`str.isidentifier`).
    )Úisidentifierr   r   r   r   r4     ó   r4   c                 C  s0   |   d¡s
|  d¡rdS tdd„ |  d¡D ƒƒS )z•
    Python "dotted identifier", i.e. a sequence of :obj:`python_identifier`
    concatenated with ``"."`` (e.g.: ``package.module.submodule``).
    r2   Fc                 s  ó   � | ]}t |ƒV  qd S r!   r3   )r"   Úmr   r   r   r$   '  r%   z.python_qualified_identifier.<locals>.<genexpr>)re   rp   r9   r8   r   r   r   r   Úpython_qualified_identifier   s   rƒ   c                 C  s   t | ƒS )zsModule name that can be used in an ``import``-statement in Python.
    See :obj:`python_qualified_identifier`.
    )rƒ   r   r   r   r   rq   *  r€   rq   c                 C  s6   |   d¡s
|  d¡rdS |  d¡rdS t|  dd¡ƒS )a±  Similar to :obj:`python_module_name`, but relaxed to also accept
    dash characters (``-``) and cover special cases like ``pip-run``.

    It is recommended, however, that beginners avoid dash characters,
    as they require advanced knowledge about Python internals.

    The following are disallowed:

    * names starting/ending in dashes,
    * names ending in ``-stubs`` (potentially collide with :obj:`pep561_stub_name`).
    ú-Fro   r;   )re   rp   rq   Úreplacer   r   r   r   Úpython_module_name_relaxed1  s
   
r†   c                 C  r	   )zhSee ``Data model > group`` in the :ref:`PyPA's entry-points specification
    <pypa:entry-points>`.
    N)ÚENTRYPOINT_GROUP_REGEXr   r   r   r   r   Úpython_entrypoint_groupD  r   rˆ   c                 C  s:   t  | ¡sdS t | ¡sd| › d�}|t7 }t |¡ dS )zgSee ``Data model > name`` in the :ref:`PyPA's entry-points specification
    <pypa:entry-points>`.
    FzEntry point `z'` does not follow recommended pattern: T)ÚENTRYPOINT_REGEXr   ÚRECOMMEDED_ENTRYPOINT_REGEXÚRECOMMEDED_ENTRYPOINT_PATTERNr_   r|   )r   rf   r   r   r   Úpython_entrypoint_nameK  s   


rŒ   c           	      C  sÂ   |   d¡\}}}d|v rC|  d¡\}}}| ¡ d dkrdS dd„ | tjd ¡ d	¡D ƒ}td
d„ |D ƒƒs9dS t d| › d�¡ n|}| d¡}|rTt|| d¡ƒnt	|ƒ}tdd„ |D ƒƒS )zÑReference to a Python object using in the format::

        importable.module:object.attr

    See ``Data model >object reference`` in the :ref:`PyPA's entry-points specification
    <pypa:entry-points>`.
    r,   ú[éÿÿÿÿr'   Fc                 s  r-   r!   r.   )r"   Úxr   r   r   r$   e  r%   z.python_entrypoint_reference.<locals>.<genexpr>z[]ú,c                 s  r�   r!   )r   )r"   Úer   r   r   r$   f  r%   ú`z4` - using extras for entry points is not recommendedr2   c                 s  s   � | ]	}t | ¡ ƒV  qd S r!   )r4   r/   r0   r   r   r   r$   n  r5   )
r6   r/   ÚstringÚ
whitespacer8   r9   r_   r|   r7   Úiter)	r   r:   r;   Úrestr<   Úextras_ÚextrasÚmodule_partsr=   r   r   r   Úpython_entrypoint_referenceX  s    
rš   úbuiltins.intc                 C  ó   d|   ko	dk S   S )z/Unsigned 8-bit integer (:math:`0 \leq x < 2^8`)r   é   r   r   r   r   r   Úuint8q  ó   rž   c                 C  rœ   )z3Unsigned 16-bit integer (:math:`0 \leq x < 2^{16}`)r   i   r   r   r   r   r   Úuint16v  rŸ   r    c                 C  rœ   )z3Unsigned 32-bit integer (:math:`0 \leq x < 2^{32}`)r   l        r   r   r   r   r   Úuint32{  rŸ   r¡   c                 C  rœ   )z3Unsigned 64-bit integer (:math:`0 \leq x < 2^{64}`)r   ì            r   r   r   r   r   Úuint64€  rŸ   r£   c                 C  rœ   )z1Signed 64-bit integer (:math:`0 \leq x < 2^{64}`)r   r¢   r   r   r   r   r   Úuint…  rŸ   r¤   c                 C  rœ   )z4Signed 8-bit integer (:math:`-2^{7} \leq x < 2^{7}`)i€ÿÿÿé€   r   r   r   r   r   Úint8Š  rŸ   r¦   c                 C  rœ   )z7Signed 16-bit integer (:math:`-2^{15} \leq x < 2^{15}`)i €ÿÿi €  r   r   r   r   r   Úint16�  rŸ   r§   c                 C  rœ   )z7Signed 32-bit integer (:math:`-2^{31} \leq x < 2^{31}`)i   €l        r   r   r   r   r   Úint32”  rŸ   r¨   c                 C  rœ   ©z7Signed 64-bit integer (:math:`-2^{63} \leq x < 2^{63}`)lûÿÿÿ         l            r   r   r   r   r   Úint64™  rŸ   rª   c                 C  rœ   r©   r   r   r   r   r   Úintž  rŸ   r«   )Úlicensesc                 C  r   )z‚See :ref:`PyPA's License-Expression specification
        <pypa:core-metadata-license-expression>` (added in :pep:`639`).
        FT)Ú	_licensesÚcanonicalize_license_expressionÚInvalidLicenseExpressionr   r   r   r   ÚSPDX¦  r   r°   zžCould not find an up-to-date installation of `packaging`. License expressions might not be validated. To enforce validation, please install `packaging>=24.2`.c                 C  r   r   r   r   r   r   r   r°   ·  r    aP  
    ^                                  # start of string
        [A-Za-z_][A-Za-z_0-9]+         # a valid Python identifier
        (?:\.[A-Za-z_][A-Za-z_0-9]*)*  # optionally followed by .identifier's
    (?:\s*;\s*private)?                # optionally followed by ; private
    $                                  # end of string
    c                 C  s>   t  | ¡du r	dS |  d¡\}}}tdd„ | ¡  d¡D ƒƒS )z´This is a valid import name. It has to be series of python identifiers
    (not keywords), separated by dots, optionally followed by a semicolon and
    the keyword "private".
    NFr&   c                 s  s   � | ]	}t  |¡ V  qd S r!   )ÚkeywordÚ	iskeyword)r"   Úidentr   r   r   r$   Ð  r5   zimport_name.<locals>.<genexpr>r2   )ÚVALID_IMPORT_NAMEr   r6   r9   Úrstripr8   )r   Úidentsr;   r   r   r   Úimport_nameÇ  s   r·   )r   r   r   r   )r   r   r   r   rh   )r   r   )r   r›   r   r   )Irk   Ú
__future__r   r±   Úloggingr]   Úrer“   ÚtypingÚ	itertoolsr   r7   ÚTYPE_CHECKINGÚbuiltinsÚtyping_extensionsr   Ú	getLoggerrU   r_   ÚVERSION_PATTERNÚcompileÚVERBOSEÚ
IGNORECASEr
   r   ÚPEP508_IDENTIFIER_PATTERNr   r   Ú	packagingr   r   ÚImportErrorÚsetuptools._vendor.packagingr   r|   r+   r>   rO   rP   Útrove_classifiersrm   rn   rS   rv   rL   ÚENTRYPOINT_PATTERNr‰   r‹   rŠ   ÚENTRYPOINT_GROUP_PATTERNr‡   r4   rƒ   rq   r†   rˆ   rŒ   rš   rž   r    r¡   r£   r¤   r¦   r§   r¨   rª   r«   r¬   r­   r°   r´   r·   r   r   r   r   Ú<module>   sª    	
ÿ


þ
ÿù


5
ÿ

ÿ


















ÿùø