a
    hbòf  ã                   @   s�   d Z ddlmZ ddlmZ zHd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yz   dZY n0 G dd„ deƒZdS )zCdistutils.command.check

Implements the Distutils 'check' command.
é    )Ú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   ú`/home/httpd/docs/test/DocsMgr/lib/python3.9/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_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                   @   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 )Úcheckz6This 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_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 )z*Counts the number of warnings that occurs.r)   )r*   r   Úwarn)r   Úmsgr   r   r   r.   :   s    z
check.warnc                 C   sL   | j r|  ¡  | jr0tr"|  ¡  n| jr0tdƒ‚| jrH| jdkrHtdƒ‚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   r*   r+   r   r   r   Úrun?   s    
z	check.runc                 C   sŠ   | j j}g }dD ]"}t||ƒr(t||ƒs| |¡ q|rL|  dd |¡ ¡ |jrd|js†|  d¡ n"|j	r||j
s†|  d¡ n
|  d¡ dS )a  Ensures that all required elements of meta-data are supplied.

        Required fields:
            name, version, URL

        Recommended fields:
            (author and author_email) or (maintainer and maintainer_email))

        Warns if any are missing.
        )Ú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 suppliedN)Údistributionr#   ÚhasattrÚgetattrr   r.   ÚjoinÚauthorÚauthor_emailÚ
maintainerÚmaintainer_email)r   r#   ÚmissingÚattrr   r   r   r0   O   s    zcheck.check_metadatac                 C   sX   | j  ¡ }|  |¡D ]>}|d  d¡}|du r8|d }nd|d |f }|  |¡ qdS )z4Checks if the long string fields are reST-compliant.éÿÿÿÿÚlineNr)   z%s (line %s))r7   Úget_long_descriptionÚ_check_rst_dataÚgetr.   )r   ÚdataÚwarningrB   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 n< tyÀ } z$|j dd| d	i f¡ W Y d}~n
d}~0 0 |jS )
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.Ú )r7   Úscript_namer   r   ÚOptionParserÚ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ÚparserÚsettingsÚreporterrN   Úer   r   r   rD   {   s.    úÿzcheck._check_rst_dataN)r   r    r!   Ú__doc__ÚdescriptionÚuser_optionsÚboolean_optionsr,   r-   r.   r3   r0   r2   rD   r   r   r   r   r"   #   s   !r"   N)rV   Údistutils.corer   Údistutils.errorsr   Zdocutils.utilsr   Zdocutils.parsers.rstr   Zdocutilsr   r   r   r1   Ú	Exceptionr"   r   r   r   r   Ú<module>   s   
