B M��j��@s�dZddlmZddlmZyTddlmZddlmZddl m Z ddl m Z ddl m Z Gd d �d e�Zd ZWnek r�d ZYnXGd d�de�ZdS)zCdistutils.command.check Implements the Distutils 'check' command. �)�Command)�DistutilsSetupError)�Reporter)�Parser)�frontend)�nodes)�StringIOc@seZdZd dd�Zdd�ZdS) �SilentReporterNr�ascii�replacec Cs"g|_t�||||||||�dS)N)�messagesr�__init__)�self�source� report_level� halt_level�stream�debug�encoding� error_handler�r�</opt/alt/python37/lib64/python3.7/distutils/command/check.pyr szSilentReporter.__init__cOs6|j�||||f�tj|f|�||j|d�|��S)N)�level�type)r �appendr�system_messageZlevels)rr�messageZchildren�kwargsrrrrszSilentReporter.system_message)Nrr r )�__name__� __module__� __qualname__r rrrrrr s r TFc@s`eZdZdZdZdddgZdddgZd d �Zd d �Zd d�Z dd�Z dd�Z dd�Z dd�Z dS)�checkz6This command checks the meta-data of the package. z"perform some checks on the package)�metadata�mzVerify meta-data)�restructuredtext�rzEChecks if long string meta-data syntax are reStructuredText-compliant)�strict�sz(Will exit with an error if a check failsr"r$r&cCsd|_d|_d|_d|_dS)z Sets default values for options.r�N)r$r"r&� _warnings)rrrr�initialize_options1szcheck.initialize_optionscCsdS)Nr)rrrr�finalize_options8szcheck.finalize_optionscCs|jd7_t�||�S)z*Counts the number of warnings that occurs.r()r)r�warn)r�msgrrrr,;sz check.warncCsL|jr|��|jr0tr"|��n|jr0td��|jrH|jdkrHtd��dS)zRuns the command.zThe docutils package is needed.rzPlease correct your package.N)r"�check_metadatar$� HAS_DOCUTILS�check_restructuredtextr&rr))rrrr�run@s z check.runcCs�|jj}g}x*dD]"}t||�r*t||�s|�|�qW|rP|�dd�|��|jrh|js�|�d�n"|j r�|j s�|�d�n |�d�dS)z�Ensures that all required elements of meta-data are supplied. name, version, URL, (author and author_email) or (maintainer and maintainer_email)). Warns if any are missing. )�name�versionZurlzmissing required meta-data: %sz, zLmissing meta-data: if 'author' supplied, 'author_email' must be supplied toozTmissing meta-data: if 'maintainer' supplied, 'maintainer_email' must be supplied toozimissing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be suppliedN) � distributionr"�hasattr�getattrrr,�joinZauthorZ author_emailZ maintainerZmaintainer_email)rr"Zmissing�attrrrrr.Ps   zcheck.check_metadatacCs\|j��}xL|�|�D]>}|d�d�}|dkr:|d}nd|d|f}|�|�qWdS)z4Checks if the long string fields are reST-compliant.����lineNr(z %s (line %s))r4Zget_long_description�_check_rst_data�getr,)r�dataZwarningr:rrrr0ns  zcheck.check_restructuredtextc Cs�|jjp d}t�}tjtfd���}d|_d|_d|_t ||j |j |j |j |j|jd�}tj|||d�}|�|d�y|�||�Wn:tk r�}z|j�dd|d if�Wdd}~XYnX|jS) z8Returns warnings when the provided data doesn't compile.zsetup.py)Z components�N)rrrr)rr9z!Could not finish the parsing: %s.�)r4Z script_namerrZ OptionParserZget_default_valuesZ tab_widthZpep_referencesZrfc_referencesr rrZwarning_streamrZerror_encodingZerror_encoding_error_handlerr�documentZ note_source�parse�AttributeErrorr r)rr=� source_path�parserZsettingsZreporterr@�errrr;ys*   $zcheck._check_rst_dataN)rrr �__doc__Z descriptionZ user_optionsZboolean_optionsr*r+r,r1r.r0r;rrrrr!$s  r!N)rFZdistutils.corerZdistutils.errorsrZdocutils.utilsrZdocutils.parsers.rstrZdocutilsrr�iorr r/� Exceptionr!rrrr�<module>s