o
    5‘ðiR  ã                   @   s¢   d Z ddlZddlmZ ddlmZ ddlmZ e e	¡�" ddl
ZddlZddlZddlZG dd„ dejjƒZW d  ƒ n1 sBw   Y  G d	d
„ d
eƒZdS )zCdistutils.command.check

Implements the Distutils 'check' command.
é    N)ÚClassVaré   )ÚCommand)ÚDistutilsSetupErrorc                       s.   e Zd Z				d	‡ fdd„	Zdd„ Z‡  ZS )
ÚSilentReporterNFÚasciiÚreplacec              	      s"   g | _ tƒ  |||||||¡ d S ©N)ÚmessagesÚsuperÚ__init__)ÚselfÚsourceÚreport_levelÚ
halt_levelÚstreamÚdebugÚencodingÚerror_handler©Ú	__class__© úb/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/_distutils/command/check.pyr      s   
ÿzSilentReporter.__init__c                 O   s:   | j  ||||f¡ tjj|g|¢R || j| dœ|¤ŽS )N)ÚlevelÚtype)r
   ÚappendÚdocutilsÚnodesÚsystem_messageÚlevels)r   r   ÚmessageÚchildrenÚkwargsr   r   r   r   "   s   ÿÿ
ÿÿzSilentReporter.system_message)NFr   r   )Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__r   r   r   r   r      s    ør   c                   @   sˆ   e Zd ZU dZdZg d¢Zeeee	e	e	f   e
d< g d¢Zeee	  e
d< dd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )Úcheckz1This command checks the meta-data of the package.z"perform some checks on the package))ÚmetadataÚmzVerify meta-data)ÚrestructuredtextÚrzEChecks if long string meta-data syntax are reStructuredText-compliant)ÚstrictÚsz(Will exit with an error if a check failsÚuser_options)r(   r*   r,   Úboolean_optionsc                 C   s   d| _ d| _d| _d| _dS )z Sets default values for options.Fé   r   N)r*   r(   r,   Ú	_warnings©r   r   r   r   Úinitialize_options9   s   
zcheck.initialize_optionsc                 C   s   d S r	   r   r2   r   r   r   Úfinalize_options@   s   zcheck.finalize_optionsc                 C   s   |  j d7  _ t | |¡S )z*Counts the number of warnings that occurs.r0   )r1   r   Úwarn)r   Úmsgr   r   r   r5   C   s   z
check.warnc              
   C   s~   | j r|  ¡  | jr/dtƒ v r(z|  ¡  W n ty' } ztt|ƒƒ‚d}~ww | jr/tdƒ‚| jr;| j	dkr=tdƒ‚dS dS )zRuns the command.r   NzThe docutils package is needed.r   zPlease correct your package.)
r(   Úcheck_metadatar*   ÚglobalsÚcheck_restructuredtextÚ	TypeErrorr   Ústrr,   r1   )r   Úexcr   r   r   ÚrunH   s   
€ÿÿz	check.runc                    s<   | j j‰ ‡ fdd„dD ƒ}|r|  d d |¡¡¡ dS dS )z�Ensures that all required elements of meta-data are supplied.

        Required fields:
            name, version

        Warns if any are missing.
        c                    s   g | ]
}t ˆ |d ƒs|‘qS r	   )Úgetattr)Ú.0Úattr©r(   r   r   Ú
<listcomp>e   s
    ÿÿz(check.check_metadata.<locals>.<listcomp>)ÚnameÚversionzmissing required meta-data: {}z, N)Údistributionr(   r5   ÚformatÚjoin)r   Úmissingr   rA   r   r7   [   s   
ÿÿzcheck.check_metadatac                 C   s\   | j  ¡ }|  |¡D ]!}|d  d¡}|du r|d }n
|d › d|› d�}|  |¡ q
dS )z4Checks if the long string fields are reST-compliant.éÿÿÿÿÚlineNr0   z (line ú))rE   Úget_long_descriptionÚ_check_rst_dataÚgetr5   )r   ÚdataÚwarningrJ   r   r   r   r9   l   s   

úzcheck.check_restructuredtextc              
   C   sâ   | j jpd}tjj ¡ }tjjtjjjfd� ¡ }d|_	d|_
d|_t||j|j|j|j|j|jd�}tjj|||d�}| |d¡ z
| ||¡ W |jS  ttfyp } z|j dd|› d	�d
i f¡ W Y d}~|jS d}~ww )z8Returns warnings when the provided data doesn't compile.zsetup.py)Ú
componentsé   N)r   r   r   r   )r   rI   zCould not finish the parsing: Ú.Ú )rE   Úscript_namer   ÚparsersÚrstÚParserÚfrontendÚOptionParserÚget_default_valuesÚ	tab_widthÚpep_referencesÚrfc_referencesr   r   r   Úwarning_streamr   Úerror_encodingÚerror_encoding_error_handlerr   ÚdocumentÚnote_sourceÚparseÚAttributeErrorr:   r
   r   )r   rO   Úsource_pathÚparserÚsettingsÚreporterrb   Úer   r   r   rM   w   sD   
ÿþù
	ø
ü€øzcheck._check_rst_dataN)r#   r$   r%   Ú__doc__Údescriptionr.   r   ÚlistÚtupler;   Ú__annotations__r/   r3   r4   r5   r=   r7   r9   rM   r   r   r   r   r'   )   s   
 "
r'   )rk   Ú
contextlibÚtypingr   Úcorer   Úerrorsr   ÚsuppressÚImportErrorÚdocutils.frontendr   Údocutils.nodesÚdocutils.parsers.rstÚdocutils.utilsÚutilsÚReporterr   r'   r   r   r   r   Ú<module>   s    ú