o
    bb                     @   s   d Z ddlmZ 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yC   dZY nw G dd deZdS )zCdistutils.command.check

Implements the Distutils 'check' command.
    )getaddresses)Command)DistutilsSetupError)Reporter)Parser)frontend)nodesc                       s.   e Zd Z				d	 fdd	Zdd Z  ZS )
SilentReporterNr   asciireplacec              	      s"   g | _ t ||||||| d S N)messagessuper__init__)selfsourcereport_level
halt_levelstreamdebugencodingerror_handler	__class__ home/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/setuptools/_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_messagelevels)r   r   messagechildrenkwargsr   r   r   r   !   s   
zSilentReporter.system_message)Nr   r
   r   )__name__
__module____qualname__r   r   __classcell__r   r   r   r   r	      s    r	   TFc                   @   s\   e Zd 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 )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)r)   r+   r-   c                 C   s   d| _ d| _d| _d| _dS )z Sets default values for options.r      N)r+   r)   r-   	_warningsr   r   r   r   initialize_optionsA   s   
zcheck.initialize_optionsc                 C   s   d S r   r   r1   r   r   r   finalize_optionsH   s   zcheck.finalize_optionsc                 C   s   |  j d7  _ t| |S )z*Counts the number of warnings that occurs.r/   )r0   r   warn)r   msgr   r   r   r4   K   s   z
check.warnc                 C   sP   | j r|   | jrtr|   n| jrtd| jr$| jdkr&tddS dS )zRuns the command.zThe docutils package is needed.r   zPlease correct your package.N)r)   check_metadatar+   HAS_DOCUTILScheck_restructuredtextr-   r   r0   r1   r   r   r   runP   s   
z	check.runc                 C   sL   | j j}g }dD ]}t||ds|| q|r$| dd|  dS dS )zEnsures that all required elements of meta-data are supplied.

        Required fields:
            name, version

        Warns if any are missing.
        )nameversionNzmissing required meta-data: %sz, )distributionr)   getattrr   r4   join)r   r)   missingattrr   r   r   r6   `   s   
zcheck.check_metadatac                 C   sX   | j  }| |D ]}|d d}|du r|d }nd|d |f }| | q
dS )z4Checks if the long string fields are reST-compliant.lineNr/   z%s (line %s))r<   get_long_description_check_rst_datagetr4   )r   datawarningrB   r   r   r   r8   r   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yd } z|j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   rA   z!Could not finish the parsing: %s. )r<   script_namer   r   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   rF   source_pathparserZsettingsZreporterrM   er   r   r   rD   }   s6   
zcheck._check_rst_dataN)r$   r%   r&   __doc__descriptionuser_optionsboolean_optionsr2   r3   r4   r9   r6   r8   rD   r   r   r   r   r(   .   s    r(   N)rS   email.utilsr   distutils.corer   distutils.errorsr   Zdocutils.utilsr   Zdocutils.parsers.rstr   Zdocutilsr   r   r	   r7   	Exceptionr(   r   r   r   r   <module>   s    