3 \xã @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|_tj||||||||ƒdS)N)ÚmessagesrÚ__init__)ÚselfÚsourceÚ report_levelÚ halt_levelÚstreamÚdebugÚencodingÚ error_handler©rú//usr/lib64/python3.6/distutils/command/check.pyr szSilentReporter.__init__cOs6|jj||||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`eZdZdZdZdddgZddd gZd d „Zdd„Zdd„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ÚmúVerify meta-dataÚrestructuredtextÚrúEChecks if long string meta-data syntax are reStructuredText-compliantÚstrictÚsú(Will exit with an error if a check failscCsd|_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_tj||ƒS)z*Counts the number of warnings that occurs.r+)r,rÚwarn)rÚmsgrrrr/;sz check.warncCsL|jr|jƒ|jr0tr"|jƒ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||ƒo(t||ƒs|j|ƒqW|rP|jddj|ƒƒ|jrh|jsŠ|jdƒn"|j r€|j sŠ|jdƒn |jdƒd S)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ÚversionÚurlzmissing required meta-data: %sz, z)missing meta-data: if 'author' supplied, z#'author_email' must be supplied tooz-missing meta-data: if 'maintainer' supplied, z''maintainer_email' must be supplied tooz4missing meta-data: either (author and author_email) z%or (maintainer and maintainer_email) zmust be suppliedN)r5r6r7zLmissing meta-data: if 'author' supplied, 'author_email' must be supplied toozTmissing meta-data: if 'maintainer' supplied, 'maintainer_email' must be supplied toozYmissing meta-data: either (author and author_email) or (maintainer and maintainer_email) zimissing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied) Ú distributionr"ÚhasattrÚgetattrrr/ÚjoinZauthorZ author_emailZ maintainerZmaintainer_email)rr"ZmissingÚattrrrrr1Ps$ zcheck.check_metadatacCs\|jjƒ}xL|j|ƒD]>}|djdƒ}|dkr:|d}nd|d|f}|j|ƒqWdS)z4Checks if the long string fields are reST-compliant.r+ÚlineNz %s (line %s)éÿÿÿÿ)r8Zget_long_descriptionÚ_check_rst_dataÚgetr/)rÚdataZwarningr=rrrr3ns  zcheck.check_restructuredtextcCsÀtƒ}tƒ}tjtfd�jƒ}d|_d|_d|_t||j |j |j |j |j |jd�}tj|||d�}|j|d ƒy|j||ƒWn:tk r¸}z|jjd d|difƒWYdd}~XnX|jS) z8Returns warnings when the provided data doesn't compile.)Z componentséN)rrrr)rr+z!Could not finish the parsing: %s.Úr>r>)rrrZ OptionParserZget_default_valuesZ tab_widthZpep_referencesZrfc_referencesr rrZwarning_streamrZerror_encodingZerror_encoding_error_handlerrÚdocumentZ note_sourceÚparseÚAttributeErrorr r)rrAÚ source_pathÚparserZsettingsZreporterrDÚerrrr?ys*  $zcheck._check_rst_dataN)r"r#r$)r%r&r')r(r)r*)rrr Ú__doc__Z descriptionZ user_optionsZboolean_optionsr-r.r/r4r1r3r?rrrrr!$s  r!N)rJZdistutils.corerZdistutils.errorsrZdocutils.utilsrZdocutils.parsers.rstrZdocutilsrrÚiorr r2Ú Exceptionr!rrrrÚs