3 \x ã @ sž d Z ddlmZ ddlmZ yTddlmZ ddlmZ ddl m Z ddl mZ ddlm Z G d d „ d eƒZdZW n ek rˆ dZY nX G d d„ deƒZdS )zCdistutils.command.check Implements the Distutils 'check' command. é )ÚCommand)ÚDistutilsSetupError)ÚReporter)ÚParser)Úfrontend)Únodes)ÚStringIOc @ s e Zd Zd dd„Zdd„ ZdS ) ÚSilentReporterNr ÚasciiÚreplacec C s" g | _ tj| |||||||ƒ d S )N)Úmessagesr Ú__init__)ÚselfÚsourceÚreport_levelÚ halt_levelÚstreamÚdebugÚencodingÚ error_handler© r ú//usr/lib64/python3.6/distutils/command/check.pyr s zSilentReporter.__init__c O s6 | j j||||fƒ tj|f|ž|| j| dœ|—ŽS )N)ÚlevelÚtype)r Úappendr Úsystem_messageZlevels)r r ÚmessageZchildrenÚkwargsr 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 ZdZdZdddgZddd gZdd „ Zdd„ Zdd„ Z dd„ Z dd„ Zdd„ Zdd„ 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 failsc C s d| _ d| _d| _d| _dS )z Sets default values for options.r é N)r% r" r( Ú _warnings)r r r r Úinitialize_options1 s zcheck.initialize_optionsc C s d S )Nr )r r r r Úfinalize_options8 s zcheck.finalize_optionsc C s | j d7 _ tj| |ƒ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| jƒ | jr0tr"| jƒ n| jr0tdƒ‚| jrH| jdkrHtdƒ‚dS )zRuns the command.zThe docutils package is needed.r zPlease correct your package.N)r" Úcheck_metadatar% ÚHAS_DOCUTILSÚcheck_restructuredtextr( r r, )r r r r Úrun@ s z check.runc C sŽ | j j}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)r5 r6 r7 zLmissing 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Úgetattrr r/ ÚjoinZauthorZauthor_emailZ maintainerZmaintainer_email)r r" ZmissingÚattrr r r r1 P s$ zcheck.check_metadatac C s\ | j jƒ }xL| j|ƒD ]>}|d jdƒ}|dkr:|d }nd|d |f }| j|ƒ qW dS )z4Checks if the long string fields are reST-compliant.r+ ÚlineNz%s (line %s)éÿÿÿÿ)r8 Zget_long_descriptionÚ_check_rst_dataÚgetr/ )r ÚdataZwarningr= r r r r3 n s zcheck.check_restructuredtextc C sÀ t ƒ }tƒ }tjtfd�jƒ }d|_d|_d|_t||j |j |j|j|j |jd�}tj|||d�}|j|d ƒ y|j||ƒ W n: tk r¸ } z|jjd d| di fƒ W Y dd}~X nX |jS )z8Returns warnings when the provided data doesn't compile.)Z componentsé N)r r r r )r r+ z!Could not finish the parsing: %s.Ú r> r> )r r r ZOptionParserZget_default_valuesZ tab_widthZpep_referencesZrfc_referencesr r r Zwarning_streamr Zerror_encodingZerror_encoding_error_handlerr ÚdocumentZnote_sourceÚparseÚAttributeErrorr r )r rA Úsource_pathÚparserZsettingsZreporterrD Úer r r r? y s* $zcheck._check_rst_dataN)r" r# r$ )r% r&