a
    ñ»j@  ã                   @   s–   d Z ddlZddlmZ ddlmZ e e¡�D 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 sx0    Y  G dd	„ d	eƒZdS )
zCdistutils.command.check

Implements the Distutils 'check' command.
é    Né   )Ú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__© úIE:\soccer\ml_env\Lib\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_messageZ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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.Fé   r   N)r(   r&   r*   Ú	_warnings©r   r   r   r   Úinitialize_options;   s    zcheck.initialize_optionsc                 C   s   d S r   r   r.   r   r   r   Úfinalize_optionsB   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   r1   E   s    z
check.warnc              
   C   sˆ   | j r|  ¡  | jrldtƒ v r^z|  ¡  W ql tyZ } ztt|ƒƒ‚W Y d}~qld}~0 0 n| jrltdƒ‚| jr„| j	dkr„tdƒ‚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*   r-   )r   Úexcr   r   r   ÚrunJ   s    
$z	check.runc                 C   sJ   | j j}g }dD ]}t||dƒs| |¡ q|rF|  d d |¡¡¡ dS )z�Ensures that all required elements of meta-data are supplied.

        Required fields:
            name, version

        Warns if any are missing.
        )ÚnameÚversionNzmissing required meta-data: {}z, )Údistributionr&   Úgetattrr   r1   ÚformatÚjoin)r   r&   ÚmissingÚattrr   r   r   r3   ]   s    zcheck.check_metadatac                 C   s\   | j  ¡ }|  |¡D ]B}|d  d¡}|du r8|d }n|d › d|› d�}|  |¡ qdS )z4Checks if the long string fields are reST-compliant.éÿÿÿÿÚlineNr,   z (line ú))r<   Úget_long_descriptionÚ_check_rst_dataÚgetr1   )r   ÚdataÚwarningrC   r   r   r   r5   o   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 n@ tyÔ } z(|j d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   rB   zCould not finish the parsing: Ú.Ú )r<   Úscript_namer   ÚparsersÚrstÚParserZfrontendÚ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   rH   Úsource_pathÚparserÚsettingsÚreporterrT   Úer   r   r   rF   z   s:    
ÿ
ù

üzcheck._check_rst_dataN)r!   r"   r#   Ú__doc__ÚdescriptionÚuser_optionsÚboolean_optionsr/   r0   r1   r9   r3   r5   rF   r   r   r   r   r%   (   s   r%   )r\   Ú
contextlibÚcorer   Úerrorsr   ÚsuppressÚImportErrorZdocutils.frontendr   Zdocutils.nodesZdocutils.parsers.rstZdocutils.utilsÚutilsZReporterr   r%   r   r   r   r   Ú<module>   s   2