o
    5‘ðiÊ  ã                   @   sô   d 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	 ddl
mZ e	de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edefdd„Zdedefdd„Zdee deeddf fdd„Zdedefdd„ZeeefZdS )z«The purpose of this module is implement PEP 621 validations that are
difficult to express as a JSON Schema (or that are not supported by the current
JSON Schema library).
é    N)Úcleandoc)Ú	GeneratorÚIterableÚMappingÚTypeVaré   )ÚValidationErrorÚT)Úboundc                   @   ó   e Zd ZdZeZdZdS )ÚRedefiningStaticFieldAsDynamicz˜According to PEP 621:

    Build back-ends MUST raise an error if the metadata specifies a field
    statically as well as being listed in dynamic.
    zMhttps://packaging.python.org/en/latest/specifications/pyproject-toml/#dynamicN©Ú__name__Ú
__module__Ú__qualname__Ú_DESCÚ__doc__Ú_URL© r   r   úv/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/config/_validate_pyproject/extra_validations.pyr      s
    ÿr   c                   @   r   )Ú IncludedDependencyGroupMustExistzDAn included dependency group must exist and must not be cyclic.
    z!https://peps.python.org/pep-0735/Nr   r   r   r   r   r      s    r   c                   @   r   )ÚImportNameCollisionz\According to PEP 794:

    All import-names and import-namespaces items must be unique.
    ú!https://peps.python.org/pep-0794/Nr   r   r   r   r   r   #   ó    r   c                   @   r   )ÚImportNameMissingzLAccording to PEP 794:

    An import name must have all parents listed.
    r   Nr   r   r   r   r   r   ,   r   r   Ú	pyprojectÚreturnc              	   C   sl   |   di ¡}|  dg ¡}|D ]%}||v r3td|› d�||| ddd|id|› �ttjƒtjdœd	d
�‚q| S )NÚprojectÚdynamicz(You cannot provide a value for `project.z6` and list it under `project.dynamic` at the same timez...z # ...zdata.project.©ÚdescriptionÚseezPEP 621©ÚmessageÚvalueÚnameÚ
definitionÚrule)Úgetr   r   r   r   )r   Úproject_tabler   Úfieldr   r   r   Úvalidate_project_dynamic5   s$   
ýþóÿr+   c              	   C   sz   |   di ¡}| ¡ D ]0\}}|D ])}t|tƒr9|  d¡ }r9||vr9td|› d�|d|› �ttjƒtjdœdd�‚qq
| S )	Nzdependency-groupszinclude-groupzThe included dependency group z doesn't existzdata.dependency_groups.r   zPEP 735r"   )r(   ÚitemsÚ
isinstanceÚdictr   r   r   r   )r   Údependency_groupsÚkeyr$   ÚeachÚinclude_groupr   r   r   Úvalidate_include_depenencyN   s(   ÿþ
þø€úr3   r,   c                 c   s$   � | D ]}|  d¡d  ¡ V  qd S )Nú;r   )Ú	partitionÚrstrip)r,   Úitemr   r   r   Ú_remove_privatee   s   €ÿr8   c              	   C   sØ   |   di ¡}t t|  dg ¡ƒ¡}t t|  dg ¡ƒ¡}dd„ ||  ¡ D ƒ}|r9td|dttjƒtjdœd	d
�‚t	|| ƒ}|D ](}t
 | d¡d d… dd„ ¡D ]}||vrhtd|dttjƒtjdœd	d
�‚qRqA| S )Nr   zimport-nameszimport-namespacesc                 S   s   g | ]
\}}|d kr|‘qS )r   r   )Ú.0ÚkÚvr   r   r   Ú
<listcomp>q   s    z/validate_import_name_issues.<locals>.<listcomp>zBDuplicated names are not allowed in import-names/import-namespaceszdata.project.importnames(paces)r   zPEP 794r"   Ú.éÿÿÿÿc                 S   s   | › d|› �S )Nr=   r   )ÚaÚbr   r   r   Ú<lambda>‚   s    z-validate_import_name_issues.<locals>.<lambda>zRAll parents of an import name must also be listed in import-namespace/import-names)r(   ÚcollectionsÚCounterr8   r,   r   r   r   r   Ú	frozensetÚ	itertoolsÚ
accumulateÚsplitr   )r   r   Úimport_namesÚimport_namespacesÚ
duplicatedÚnamesr%   Úparentr   r   r   Úvalidate_import_name_issuesj   sD   ÿþøÿþøÿýrM   )r   rB   rE   Úinspectr   Útypingr   r   r   r   Úerror_reportingr   r	   r   r   r   r   r+   r3   Ústrr8   rM   ÚEXTRA_VALIDATIONSr   r   r   r   Ú<module>   s&    		 *ý