й¼]xã @sÅddlmZddlmZypddlmZddlmZddlm Z ddlm Z ddl m Z Gdd „d eƒZ d ZWnek rªd ZYnXGd d „d eƒZdS)é)ÚCommand)ÚDistutilsSetupError)ÚReporter)ÚParser)Úfrontend)Únodes)ÚStringIOc@s4eZdZdddddd„Zdd„ZdS) ÚSilentReporterNrÚasciiÚreplacec Cs/g|_tj||||||||ƒdS)N)ÚmessagesrÚ__init__)ÚselfÚsourceÚ report_levelÚ halt_levelÚstreamÚdebugÚencodingÚ error_handler©rú*/opt/alt/python35/lib64/python3.5/check.pyr s zSilentReporter.__init__cOsB|jj||||fƒtj||d|d|j||ŽS)NÚlevelÚtype)r ÚappendrÚsystem_messageZlevels)rrÚmessageZchildrenÚkwargsrrrrs zSilentReporter.system_message)Ú__name__Ú __module__Ú __qualname__r rrrrrr s r TFc@sˆeZdZdZdddgZdddgZd d „Zd d„Zdd„Zdd„Z dd„Z dd„Z dd„Z dS)Úcheckz"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 failscCs(d|_d|_d|_d|_dS)Nré)r%r"r(Ú _warnings)rrrrÚinitialize_options1s   zcheck.initialize_optionscCsdS)Nr)rrrrÚfinalize_options8szcheck.finalize_optionscCs|jd7_tj||ƒS)Nr+)r,rÚwarn)rÚmsgrrrr/;sz check.warncCsl|jr|jƒ|jrDtr/|jƒn|jrDtdƒ‚|jrh|jdkrhtdƒ‚dS)NzThe docutils package is needed.rzPlease correct your package.)r"Úcheck_metadatar%Ú HAS_DOCUTILSÚcheck_restructuredtextr(rr,)rrrrÚrun@s      z check.runcCsÓ|jj}g}x9d D]1}t||ƒo:t||ƒs|j|ƒqW|rn|jddj|ƒƒ|jr”|jsÏ|jddƒn;|j rº|j sÏ|jdd ƒn|jd d d ƒdS)NÚ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 supplied)r5r6r7) Ú distributionr"ÚhasattrÚgetattrrr/ÚjoinZauthorZ author_emailZ maintainerZmaintainer_email)rr"ÚmissingÚattrrrrr1Ps$          zcheck.check_metadatacCsz|jjƒ}xd|j|ƒD]S}|djdƒ}|dkrQ|d}nd|d|f}|j|ƒqWdS)Nr+Úlinez %s (line %s)éÿÿÿÿ)r8Zget_long_descriptionÚ_check_rst_dataÚgetr/)rÚdataÚwarningr>rrrr3ns  zcheck.check_restructuredtextcCstƒ}tƒ}tjdtfƒjƒ}d|_d|_d|_t||j |j d|j d|j d|j d|jƒ}tj||d|ƒ}|j|d ƒy|j||ƒWnEtk r}z%|jjd d |d ifƒWYdd}~XnX|jS) NZ componentsérrrrrr+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)rrBÚ source_pathÚparserZsettingsZreporterrFÚerrrr@ys*           *zcheck._check_rst_dataN)r"r#r$)r%r&r')r(r)r*) rrr Ú descriptionZ user_optionsZboolean_optionsr-r.r/r4r1r3r@rrrrr!$s        r!N)Zdistutils.corerZdistutils.errorsrZdocutils.utilsrZdocutils.parsers.rstrZdocutilsrrÚiorr r2Ú Exceptionr!rrrrÚs