o
    LK&hR                     @   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__ V/var/www/html/venv/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 )zEnsures 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    