U e5d @ s d Z ddlmZ ddlmZ zTddlmZ ddlmZ ddl m Z ddl mZ ddlm Z G d d d eZdZW n ek r dZY nX G d d deZdS )zCdistutils.command.check Implements the Distutils 'check' command. )Command)DistutilsSetupError)Reporter)Parser)frontend)nodes)StringIOc @ s e Zd Zd ddZdd ZdS ) SilentReporterNr asciireplacec C s" g | _ t| ||||||| d S N)messagesr __init__)selfsourcereport_level halt_levelstreamdebugencoding error_handler r //usr/lib64/python3.8/distutils/command/check.pyr s zSilentReporter.__init__c O s6 | j ||||f tj|f||| j| d|S )N)leveltype)r appendr system_messageZlevels)r r messageZchildrenkwargsr r r r s zSilentReporter.system_message)Nr r r )__name__ __module____qualname__r r r r r r r s r TFc @ s` e Zd ZdZdZdddgZdddgZd d Zdd Zd d Z dd Z dd Zdd Zdd Z dS )checkz6This command checks the meta-data of the package. z"perform some checks on the package)metadatamzVerify meta-data)restructuredtextrzEChecks if long string meta-data syntax are reStructuredText-compliant)strictsz(Will exit with an error if a check failsr# r% r' c C s d| _ d| _d| _d| _dS )z Sets default values for options.r N)r% r# r' _warningsr r r r initialize_options1 s zcheck.initialize_optionsc C s d S r r r+ r r r finalize_options8 s zcheck.finalize_optionsc C s | j d7 _ 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| | jr0tr"| n| jr0td| jrH| jdkrHtddS )zRuns the command.zThe docutils package is needed.r zPlease correct your package.N)r# check_metadatar% HAS_DOCUTILScheck_restructuredtextr' r r* r+ r r r run@ s z check.runc C s | j j}g }dD ]"}t||r(t||s|| q|rL| dd| |jrd|js| d n"|j r||j s| d n | d dS )zEnsures 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. )nameversionZurlzmissing 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# hasattrgetattrr r. joinZauthorZauthor_emailZ maintainerZmaintainer_email)r r# Zmissingattrr r r r0 P s zcheck.check_metadatac C sX | j }| |D ]>}|d d}|dkr8|d }nd|d |f }| | qdS )z4Checks if the long string fields are reST-compliant.lineNr) z%s (line %s))r6 Zget_long_description_check_rst_datagetr. )r dataZwarningr<