U ia@sdZddlmZddlmZzHddlmZddlmZddl m Z ddl m Z Gdd d eZ d Z Wnek r|d Z YnXGd d d eZdS)zCdistutils.command.check Implements the Distutils 'check' command. )Command)DistutilsSetupError)Reporter)Parser)frontend)nodesc@seZdZd ddZddZdS) SilentReporterNrasciireplacec Cs"g|_t||||||||dSN)messagesr__init__)selfsource report_level halt_levelstreamdebugencoding error_handlerr{/private/var/folders/k6/_7fsz4ts3b78x3b3xwrxjh_c8s8xv7/T/pip-unpacked-wheel-yl_m2el9/setuptools/_distutils/command/check.pyr s zSilentReporter.__init__cOs6|j||||ftj|f|||j|d|S)N)leveltype)r appendrsystem_messagelevels)rrmessagechildrenkwargsrrrrszSilentReporter.system_message)Nrr r )__name__ __module__ __qualname__r rrrrrrs  rTFc@s`eZdZdZdZdddgZdddgZd d Zd d Zd dZ ddZ ddZ ddZ ddZ 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(cCsd|_d|_d|_d|_dS)z Sets default values for options.rN)r&r$r( _warningsrrrrinitialize_options0szcheck.initialize_optionscCsdSr rr,rrrfinalize_options7szcheck.finalize_optionscCs|jd7_t||S)z*Counts the number of warnings that occurs.r*)r+rwarn)rmsgrrrr/:sz check.warncCsL|jr||jr0tr"|n|jr0td|jrH|jdkrHtddS)zRuns the command.zThe docutils package is needed.rzPlease correct your package.N)r$check_metadatar& HAS_DOCUTILScheck_restructuredtextr(rr+r,rrrrun?s z check.runcCs|jj}g}dD]"}t||r(t||s||q|rL|dd||jrd|js|dn"|j r||j s|dn |ddS)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. )nameversionurlzmissing 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$hasattrgetattrrr/joinauthor author_email maintainermaintainer_email)rr$missingattrrrrr1Os    zcheck.check_metadatacCsX|j}||D]>}|dd}|dkr8|d}nd|d|f}||qdS)z4Checks if the long string fields are reST-compliant.lineNr*z %s (line %s))r8get_long_description_check_rst_datagetr/)rdatawarningrCrrrr3ps  zcheck.check_restructuredtextc Cs|jjp d}t}tjtfd}d|_d|_d|_t ||j |j |j |j |j|jd}tj|||d}||dz|||Wn:tk r}z|jdd|d ifW5d}~XYnX|jS) z8Returns warnings when the provided data doesn't compile.zsetup.py) componentsN)rrrr)rrBz!Could not finish the parsing: %s.)r8 script_namerr OptionParserget_default_valuesZ tab_widthZpep_referencesZrfc_referencesrrrZwarning_streamrZerror_encodingZerror_encoding_error_handlerrdocumentZ note_sourceparseAttributeErrorr r)rrG source_pathparsersettingsZreporterrOerrrrE{s.  zcheck._check_rst_dataN)r r!r"__doc__ description user_optionsboolean_optionsr-r.r/r4r1r3rErrrrr##s ! r#N)rVdistutils.corerdistutils.errorsrZdocutils.utilsrZdocutils.parsers.rstrZdocutilsrrrr2 Exceptionr#rrrrs