
    7 f                       d Z ddlmZ ddlZddlZddlZddlZddlZddlm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZ ddlmZmZ dd	lmZ e
rdd
lmZ ddlmZ ddlmZ dZd!d"dZd#dZ  G d dej!                  Z" G d d          Z#d$d Z$dS )%zSphinx test suite utilities    )annotationsN)IOTYPE_CHECKINGAny)ElementTree)nodes)
directivesroles)applicationlocale)ModuleAnalyzer)StringIO)Path)Node)SphinxTestApp#SphinxTestAppWrapperForSkipBuilding noder   clsr   xpathstrkwargsreturnNonec                >   |rt          |t                    rt          | |d         fd|i| |dd          rt          |d         t                    rt          | |d         fd|i| nt          | t          j                  sJ d|z              t          |           dk    sJ d|t          |           fz              t          | d         |dd          fd|dz   i| nt          |t                    rt          | t          t          j        f          sJ d|z              t          |           t          |          k    s*J d|t          |           t          |          fz              t          |          D ]#\  }}|d	|z  z   }t          | |         |fd|i| $nRt          |t                    r| |k    sJ d
|d|d|             n#t          | |          sJ d| d|d|             |rt          | t          j                  sJ d|z              |	                                D ]g\  }}|| vr4|
                    dd          x}| vrd| d|d| }	t          |	          | |         |k    sJ d| d| d|d| |                     fd S d S )Nr   r      z%The node%s does not have any childrenz&The node%s has %d child nodes, not onez[0]z"The node%s does not have any itemsz%The node%s has %d child nodes, not %rz[%d]z	The node z is not z: zThe nodez is not subclass of z'The node%s does not have any attributes_-z does not have z attribute: [z	] is not )
isinstancelistassert_nodetupler   Elementlen	enumerater   itemsreplaceAssertionError)
r   r   r   r   inodeclspathkeyvaluemsgs
             I/var/www/equiseq/venv/lib/python3.11/site-packages/sphinx/testing/util.pyr"   r"      s   
 Hc4   	Hc!f<<E<V<<<122w Qc!fe,, Qc!fDDEDVDDDD%dEM:: H H?%GH H:t99>>>@E3t99CUU *>>QQRRPPPPPPU## 	HdT5=$9:: = =4u<= =:t99C(((75#d))SQTXX:VV )(('nn D D
7vz)DGWCCDCFCCCCD S!! 	H3;;; NE N NS N Nd N N;;;;dC(( H HG5GGcGGtGGH H(  
J$.. 	> 	>5=	> 	>. !,,.. 	J 	JJC$;;sC000C==VUVV3VVdVVC(---9%%%I5II3IIIIDIII &%%%
J 
J	J 	J    r,   c                    t          j        d          5  t          j        dt                     t	          j        |           cd d d            S # 1 swxY w Y   d S )NF)recordignore)category)warningscatch_warningsfilterwarningsDeprecationWarningr   parse)r,   s    r0   etree_parser;   C   s    		 	.	.	. ' '3EFFFF &&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 's   /AAAc                  p     e Zd ZU dZded<   ded<   	 	 	 	 	 	 	 	 	 	 d$d% fdZd&d'dZd(d Zd)d* fd#Z xZ	S )+r   z
    A subclass of :class:`Sphinx` that runs on the test root, with some
    better default values for the initialization parameters.
    r   _status_warninghtmlNFr   buildernamer   srcdirPath | Nonebuilddirfreshenvboolconfoverridesdict | Nonestatus	IO | Nonewarningtagslist[str] | Nonedocutilsconf
str | Noneparallelintr   r   c                   |J |dz  | _         |	| j                             |	d           ||dz  }|}|                    |          }|                    dd           |                    d          }|                    dd           |i }d}t          j        d d          | _        t          j        	                                | _
        t          j        	                                | _        d	 t          t          j                  D             | _        	 t%                                          ||||||||||||

           d S # t(          $ r |                                   w xY w)Nzdocutils.confutf8)encoding_buildT)parentsexist_okdoctreesFc                <    h | ]}|                     d           |S )visit_)
startswith).0vs     r0   	<setcomp>z)SphinxTestApp.__init__.<locals>.<setcomp>t   s8     #> #> #>&'ll8&<&<#>1 #> #> #>r1   )rO   )docutils_conf_path
write_textjoinpathmkdirsysr,   _saved_pathr	   _directivescopy_saved_directivesr
   _roles_saved_rolesdirr   GenericNodeVisitor_saved_nodeclassessuper__init__	Exceptioncleanup)selfr@   rA   rC   rD   rF   rH   rJ   rK   rM   rO   confdiroutdir
doctreedirwarningiserror	__class__s                  r0   rm   zSphinxTestApp.__init__Q   s    !!!"(?":##..|f.MMM(H"";//TD111&&z22
555 M8AAA;!+!7!<!<!>!>!L--//#> #>c%2J.K.K #> #> #>	GGVWfj(-%~th  P P P P P  	 	 	LLNNN	s   -E  E,rW   c                   t           j                                         t          j                                         | j        t          j        d d <   t          j        	                    dd            | j
        t          _        | j        t          _        t!          t"          j                  D ]j}|                    d          rS|| j        vrJt+          t"          j        d|dd          z              t+          t"          j        d|dd          z              kt-          j        t0                    5  t3          j        | j                   d d d            d S # 1 swxY w Y   d S )Nautodoc_fodderrY      depart_)r   cacheclearr   translatorsrc   rb   r,   modulespoprf   r	   rd   rh   r
   rg   ri   r   rj   rZ   rk   delattr
contextlibsuppressFileNotFoundErrorosremover^   )rp   rW   methods      r0   ro   zSphinxTestApp.cleanup   su   ""$$$  """&($///!%!7
(%233 	J 	JF  ** JT4440(VABBZ2GHHH0)fQRRj2HIII !233 	/ 	/Id-...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   2EE Ec                <    d| j         j         d| j        j        dS )N<z buildername=>)ru   __name__buildername)rp   s    r0   __repr__zSphinxTestApp.__repr__   s%    O4>*OO9JOOOOr1   	force_all	filenamesc                    | j         j                                         t                                          ||           d S N)env_pickled_doctree_cacher{   rl   build)rp   r   r   ru   s      r0   r   zSphinxTestApp.build   s8    '--///i+++++r1   )
r?   NNFNNNNNr   )r@   r   rA   rB   rC   rB   rD   rE   rF   rG   rH   rI   rJ   rI   rK   rL   rM   rN   rO   rP   r   r   )F)rW   rE   r   r   )r   r   )FN)r   rE   r   rL   r   r   )
r   
__module____qualname____doc____annotations__rm   ro   r   r   __classcell__)ru   s   @r0   r   r   I   s            "" $%) !!%#', , , , , , ,\/ / / / /P P P P, , , , , , , , , , ,r1   r   c                  *    e Zd ZdZddZdd
ZddZdS )r   z
    This class is a wrapper for SphinxTestApp to speed up the test by skipping
    `app.build` process if it is already built and there is even one output
    file.
    app_r   r   r   c                    || _         d S r   )app)rp   r   s     r0   rm   z,SphinxTestAppWrapperForSkipBuilding.__init__   s    r1   r   r   r   c                ,    t          | j        |          S r   )getattrr   )rp   r   s     r0   __getattr__z/SphinxTestAppWrapperForSkipBuilding.__getattr__   s    tx&&&r1   argsr   c                j    t          j        | j        j                  s | j        j        |i | d S d S r   )r   listdirr   rr   r   )rp   r   r   s      r0   r   z)SphinxTestAppWrapperForSkipBuilding.build   sA    z$(/** 	,DHND+F+++++	, 	,r1   N)r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   rm   r   r    r1   r0   r   r      sZ            ' ' ' ', , , , , ,r1   r   textc                .    t          j        dd|           S )Nz.*?mr   )resub)r   s    r0   strip_escseqr      s    6*b$'''r1   )Nr   )
r   r   r   r   r   r   r   r   r   r   )r,   r   r   r   )r   r   r   r   )%r   
__future__r   r   r   r   rb   r6   typingr   r   r   	xml.etreer   docutilsr   docutils.parsers.rstr	   r
   sphinxr   r   sphinx.pycoder   ior   pathlibr   docutils.nodesr   __all__r"   r;   Sphinxr   r   r   r   r1   r0   <module>r      s   ! ! " " " " " "     				 				 



  ) ) ) ) ) ) ) ) ) ) ! ! ! ! ! !       2 2 2 2 2 2 2 2 & & & & & & & & ( ( ( ( ( ( $######
@%J %J %J %J %JP' ' ' 'J, J, J, J, J,K& J, J, J,Z, , , , , , , ,(( ( ( ( ( (r1   