
    d                         d Z ddlmZ d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	e          Zd
Zn# e$ r dZY nw xY w G d de          ZdS )zCdistutils.command.check

Implements the Distutils 'check' command.
    )Command)DistutilsSetupError)Reporter)Parser)frontend)nodesc                        e Zd Z	 	 ddZd ZdS )SilentReporterNr   asciireplacec           
      J    g | _         t          j        | |||||||           d S N)messagesr   __init__)selfsourcereport_level
halt_levelstreamdebugencodingerror_handlers           )  /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/distutils/command/check.pyr   zSilentReporter.__init__   s9    DMdFL*f#X}> > > > >    c                     | j                             ||||f           t          j        |g|R || j        |         d|S )N)leveltype)r   appendr   system_messagelevels)r   r   messagechildrenkwargss        r   r   zSilentReporter.system_message   sc    M  %(F!CDDD' =)1= =u-1[-?= =5;= = =r   )Nr   r   r   )__name__
__module____qualname__r   r    r   r   r
   r
      s=        DH>G	> 	> 	> 	>	= 	= 	= 	= 	=r   r
   TFc                   P    e Zd ZdZdZg dZg dZd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )checkz6This 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                 >    d| _         d| _        d| _        d| _        dS )z Sets default values for options.r      N)r,   r*   r.   	_warningsr   s    r   initialize_optionszcheck.initialize_options0   s#     !r   c                     d S r   r'   r3   s    r   finalize_optionszcheck.finalize_options7   s    r   c                 L    | xj         dz  c_         t          j        | |          S )z*Counts the number of warnings that occurs.r1   )r2   r   warn)r   msgs     r   r8   z
check.warn:   s$    !|D#&&&r   c                     | j         r|                                  | j        r2t          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   r2   r3   s    r   runz	check.run?   s     = 	"!!!  	M M++---- M)*KLLL ; 	F4>A--%&DEEE	F 	F--r   c                    | j         j        }g }dD ]7}t          ||          rt          ||          s|                    |           8|r+|                     dd                    |          z             |j        r |j        s|                     d           dS dS |j	        r |j
        s|                     d           dS dS |                     d           dS )a
  Ensures that all required elements of meta-data are supplied.

        Required fields:
            name, version, URL

        Recommended fields:
            (author and author_email) or (maintainer and maintainer_email)

        Warns if any are missing.
        )nameversionurlzmissing required meta-data: %sz, zNmissing meta-data: if 'author' supplied, 'author_email' should be supplied toozVmissing meta-data: if 'maintainer' supplied, 'maintainer_email' should be supplied toozkmissing meta-data: either (author and author_email) or (maintainer and maintainer_email) should be suppliedN)distributionr*   hasattrgetattrr   r8   joinauthorauthor_email
maintainermaintainer_email)r   r*   missingattrs       r   r;   zcheck.check_metadataO   sJ    $-. 	% 	%DHd++ %$0G0G %t$$$ 	NII6$))G:L:LLMMM? 	,( C		 B C C C C CC C   	,, G		 F G G G G GG G II + , , , , ,r   c                     | j                                         }|                     |          D ]K}|d                             d          }|	|d         }n|d         d|d}|                     |           LdS )z4Checks if the long string fields are reST-compliant.lineNr1   z (line ))rC   get_long_description_check_rst_datagetr8   )r   datawarningrO   s       r   r=   zcheck.check_restructuredtextp   s     5577++D11 	 	G2;??6**D|!!*,3AJJJ=IIg	 	r   c           	      .   | j         j        pd}t                      }t          j        t          f                                          }d|_        d|_        d|_        t          ||j
        |j        |j        |j        |j        |j                  }t!          j        |||          }|                    |d           	 |                    ||           n8# t(          $ r+}|j                            dd|z  d	i f           Y d}~nd}~ww xY w|j        S )
z8Returns warnings when the provided data doesn't compile.zsetup.py)
components   N)r   r   r   r   )r   rN   z!Could not finish the parsing: %s. )rC   script_namer   r   OptionParserget_default_values	tab_widthpep_referencesrfc_referencesr
   r   r   warning_streamr   error_encodingerror_encoding_error_handlerr   documentnote_sourceparseAttributeErrorr   r   )r   rT   source_pathparsersettingsreporterrc   es           r   rR   zcheck._check_rst_data{   sY    '3Az(VI>>>QQSS"&"&!+"/"-!)!8 (#+#:(0(MO O O >(H[III["---	GLLx(((( 	G 	G 	G$$81<b"EG G G G G G G G	G   s   C 
D"!DDN)r$   r%   r&   __doc__descriptionuser_optionsboolean_optionsr4   r6   r8   r>   r;   r=   rR   r'   r   r   r)   r)   #   s         7KB B BL A@@O    ' ' '
F F F , , ,B	 	 	! ! ! ! !r   r)   N)rl   distutils.corer   distutils.errorsr   docutils.utilsr   docutils.parsers.rstr   docutilsr   r   r
   r<   	Exceptionr)   r'   r   r   <module>rv      s    # " " " " " 0 0 0 0 0 0''''''++++++!!!!!!= = = = = = = = LL    LLL
q! q! q! q! q!G q! q! q! q! q!s   (9 AA