509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \x  ã               @   sž   d Z ddlmZ ddlmZ yTddlmZ ddlmZ ddl	m
Z
 ddl	mZ ddlmZ G d	d
„ d
eƒZdZW n ek
rˆ   dZY nX G dd„ deƒZdS )zCdistutils.command.check

Implements the Distutils 'check' command.
é    )ÚCommand)ÚDistutilsSetupError)ÚReporter)ÚParser)Úfrontend)Únodes)ÚStringIOc               @   s   e Zd Zd	dd„Zdd„ ZdS )
ÚSilentReporterNr   ÚasciiÚreplacec          	   C   s"   g | _ tj| |||||||ƒ 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    zSilentReporter.__init__c             O   s6   | j j||||fƒ tj|f|ž|| j| dœ|—ŽS )N)ÚlevelÚtype)r   Úappendr   Úsystem_messageZlevels)r   r   ÚmessageZchildrenÚkwargsr   r   r   r      s    zSilentReporter.system_message)Nr   r
   r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r	      s    
r	   TFc               @   s`   e Zd ZdZdZdddgZddd	gZdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )Ú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| _dS )z Sets default values for options.r   é   N)r%   r"   r(   Ú	_warnings)r   r   r   r   Úinitialize_options1   s    zcheck.initialize_optionsc             C   s   d S )Nr   )r   r   r   r   Úfinalize_options8   s    zcheck.finalize_optionsc             C   s   |  j d7  _ tj| |ƒ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ƒ  | jr0tr"| jƒ  n| jr0tdƒ‚| jrH| jdkrHtdƒ‚dS )zRuns the command.zThe docutils package is needed.r   zPlease 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*dD ]"}t||ƒo(t||ƒs|j|ƒ qW |rP| jddj|ƒ ƒ |jrh|jsŠ| jdƒ n"|j	r€|j
sŠ| jdƒ n
| jdƒ 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Úurlzmissing 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) zmust 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/   ÚjoinZauthorZauthor_emailZ
maintainerZmaintainer_email)r   r"   ZmissingÚattrr   r   r   r1   P   s$    
 zcheck.check_metadatac             C   s\   | j jƒ }xL| j|ƒD ]>}|d jdƒ}|dkr:|d }nd|d |f }| j|ƒ qW dS )z4Checks if the long string fields are reST-compliant.r+   ÚlineNz%s (line %s)éÿÿÿÿ)r8   Zget_long_descriptionÚ_check_rst_dataÚgetr/   )r   ÚdataZwarningr=   r   r   r   r3   n   s    

zcheck.check_restructuredtextc             C   sÀ   t ƒ }tƒ }tjtfd�jƒ }d|_d|_d|_t||j	|j
|j|j|j|jd�}tj|||d�}|j|d	ƒ y|j||ƒ W n: tk
r¸ } z|jjd
d| di fƒ W Y dd}~X nX |jS )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   ZOptionParserZget_default_valuesZ	tab_widthZpep_referencesZrfc_referencesr	   r   r   Zwarning_streamr   Zerror_encodingZerror_encoding_error_handlerr   ÚdocumentZnote_sourceÚparseÚAttributeErrorr   r   )r   rA   Úsource_pathÚparserZsettingsZreporterrD   Úer   r   r   r?   y   s*    
$zcheck._check_rst_dataN)r"   r#   r$   )r%   r&   r'   )r(   r)   r*   )r   r   r    Ú__doc__ZdescriptionZuser_optionsZboolean_optionsr-   r.   r/   r4   r1   r3   r?   r   r   r   r   r!   $   s     
r!   N)rJ   Zdistutils.corer   Zdistutils.errorsr   Zdocutils.utilsr   Zdocutils.parsers.rstr   Zdocutilsr   r   Úior   r	   r2   Ú	Exceptionr!   r   r   r   r   Ú<module>   s   
