o
     JAf                     @   s   	 d dl mZ d dlmZ z$d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 G dd deZd	ZW n ey<   d
ZY nw G dd deZdS )    )Command)DistutilsSetupError)Reporter)Parser)frontend)nodesc                   @   s"   e Zd Z		d	ddZdd ZdS )
SilentReporterNr   asciireplacec              
   C   s"   g | _ t| ||||||| d S N)messagesr   __init__)selfsourcereport_level
halt_levelstreamdebugencodingerror_handler r   ./usr/lib/python3.10/distutils/command/check.pyr      s   zSilentReporter.__init__c                 O   s8   | j ||||f tj|g|R || j| d|S )N)leveltype)r   appendr   system_messageZlevels)r   r   messagechildrenkwargsr   r   r   r      s   zSilentReporter.system_message)Nr   r	   r
   )__name__
__module____qualname__r   r   r   r   r   r   r      s
    
r   TFc                   @   sZ   e Zd Z	 dZg dZg dZdd Zdd Zdd	 Zd
d Z	dd Z
dd Zdd ZdS )checkz"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)r#   r%   r'   c                 C   s   	 d| _ d| _d| _d| _d S )Nr      )r%   r#   r'   	_warningsr   r   r   r   initialize_options0   s
   
zcheck.initialize_optionsc                 C   s   d S r   r   r+   r   r   r   finalize_options7   s   zcheck.finalize_optionsc                 C   s   	 |  j d7  _ t| |S )Nr)   )r*   r   warn)r   msgr   r   r   r.   :   s   z
check.warnc                 C   sR   	 | j r|   | jrtr|   n| jrtd| jr%| jdkr'tdd S d S )NzThe docutils package is needed.r   zPlease correct your package.)r#   check_metadatar%   HAS_DOCUTILScheck_restructuredtextr'   r   r*   r+   r   r   r   run?   s   
z	check.runc                 C   s   	 | j j}g }dD ]}t||rt||s|| q	|r'| dd|  |jr6|js4| d d S d S |j	rE|j
sC| d d S d S | d d S )N)nameversionurlzmissing required meta-data: %sz, zNmissing meta-data: if 'author' supplied, 'author_email' should be supplied toozVmissing meta-data: if 'maintainer' supplied, 'maintainer_email' should be supplied toozkmissing meta-data: either (author and author_email) or (maintainer and maintainer_email) should be supplied)distributionr#   hasattrgetattrr   r.   joinZauthorZauthor_emailZ
maintainerZmaintainer_email)r   r#   missingattrr   r   r   r0   O   s$   

zcheck.check_metadatac                 C   sZ   	 | j  }| |D ]}|d d}|d u r|d }nd|d |f }| | qd S )Nliner)   z%s (line %s))r7   Zget_long_description_check_rst_datagetr.   )r   datawarningr>   r   r   r   r2   p   s   

zcheck.check_restructuredtextc              
   C   s   	 | j jpd}t }tjtfd }d|_d |_d |_t	||j
|j|j|j|j|jd}tj|||d}||d z
||| W |jS  tye } z|jdd| di f W Y d }~|jS d }~ww )	Nzsetup.py)
components   )r   r   r   r   )r   r=   z!Could not finish the parsing: %s. )r7   Zscript_namer   r   ZOptionParserZget_default_valuesZ	tab_widthZpep_referencesZrfc_referencesr   r   r   Zwarning_streamr   Zerror_encodingZerror_encoding_error_handlerr   documentZnote_sourceparseAttributeErrorr   r   )r   rA   source_pathparserZsettingsZreporterrF   er   r   r   r?   {   s6   zcheck._check_rst_dataN)r   r    r!   descriptionZuser_optionsZboolean_optionsr,   r-   r.   r3   r0   r2   r?   r   r   r   r   r"   #   s    !r"   N)Zdistutils.corer   Zdistutils.errorsr   Zdocutils.utilsr   Zdocutils.parsers.rstr   Zdocutilsr   r   r   r1   	Exceptionr"   r   r   r   r   <module>   s    