o
    “si  ã                   @   sœ   d Z ddlmZ ddlmZ ddlmZ 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yC   dZY nw G dd„ deƒZdS )zCdistutils.command.check

Implements the Distutils 'check' command.
é    )Úgetaddresses)ÚCommand)ÚDistutilsSetupError)ÚReporter)ÚParser)Úfrontend)Únodesc                       s.   e Zd Z				d	‡ fdd„	Zdd„ Z‡  ZS )
ÚSilentReporterNr   ÚasciiÚreplacec              	      s"   g | _ tƒ  |||||||¡ d S ©N)ÚmessagesÚsuperÚ__init__)ÚselfÚsourceÚreport_levelÚ
halt_levelÚstreamÚdebugÚencodingÚerror_handler©Ú	__class__© úrC:\Users\PC\students\dividedattentionclub\venv\lib\python3.10\site-packages\setuptools/_distutils/command/check.pyr      s   
ÿzSilentReporter.__init__c                 O   s8   | j  ||||f¡ tj|g|¢R || j| dœ|¤ŽS )N)ÚlevelÚtype)r   Úappendr   Úsystem_messageZlevels)r   r   ÚmessageÚchildrenÚkwargsr   r   r   r   !   s   ÿÿ
ÿÿzSilentReporter.system_message)Nr   r
   r   )Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__r   r   r   r   r	      s    ør	   TFc                   @   s\   e Zd ZdZdZg d¢Zg d¢Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )Úcheckz1This command checks the meta-data of the package.z"perform some checks on the package))ÚmetadataÚmzVerify meta-data)ÚrestructuredtextÚrzEChecks if long string meta-data syntax are reStructuredText-compliant)ÚstrictÚsz(Will exit with an error if a check fails)r(   r*   r,   c                 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_optionsA   s   
zcheck.initialize_optionsc                 C   s   d S r   r   r0   r   r   r   Úfinalize_optionsH   s   zcheck.finalize_optionsc                 C   s   |  j d7  _ t | |¡S )z*Counts the number of warnings that occurs.r.   )r/   r   Úwarn)r   Úmsgr   r   r   r3   K   s   z
check.warnc                 C   sP   | j r|  ¡  | jrtr|  ¡  n| jrtdƒ‚| jr$| jdkr&tdƒ‚dS 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/   r0   r   r   r   ÚrunP   s   
ÿz	check.runc                 C   sL   | j j}g }dD ]}t||dƒs| |¡ q|r$|  dd |¡ ¡ dS dS )z�Ensures that all required elements of meta-data are supplied.

        Required fields:
            name, version

        Warns if any are missing.
        )ÚnameÚversionNzmissing required meta-data: %sz, )Údistributionr(   Úgetattrr   r3   Újoin)r   r(   ÚmissingÚattrr   r   r   r5   `   s   
€ÿzcheck.check_metadatac                 C   sX   | j  ¡ }|  |¡D ]}|d  d¡}|du r|d }nd|d |f }|  |¡ q
dS )z4Checks if the long string fields are reST-compliant.éÿÿÿÿÚlineNr.   z%s (line %s))r;   Zget_long_descriptionÚ_check_rst_dataÚgetr3   )r   ÚdataÚwarningrA   r   r   r   r7   r   s   

úzcheck.check_restructuredtextc              
   C   sÊ   | j jpd}tƒ }tjtfd� ¡ }d|_d|_d|_t	||j
|j|j|j|j|jd�}tj|||d�}| |d¡ z
| ||¡ W |jS  tyd } z|j dd| d	i f¡ W Y d}~|jS d}~ww )
z8Returns warnings when the provided data doesn't compile.zsetup.py)Ú
componentsé   N)r   r   r   r   )r   r@   z!Could not finish the parsing: %s.Ú )r;   Úscript_namer   r   ÚOptionParserÚ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   rD   Úsource_pathÚparserÚsettingsÚreporterrL   Úer   r   r   rB   }   s6   ù
ûÿ€ûzcheck._check_rst_dataN)r#   r$   r%   Ú__doc__ÚdescriptionZuser_optionsZboolean_optionsr1   r2   r3   r8   r5   r7   rB   r   r   r   r   r'   .   s    r'   N)rT   Úemail.utilsr   Zdistutils.corer   Zdistutils.errorsr   Zdocutils.utilsr   Zdocutils.parsers.rstr   Zdocutilsr   r   r	   r6   Ú	Exceptionr'   r   r   r   r   Ú<module>   s    ý