HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/sphinx/testing/__pycache__/util.cpython-310.pyc
o

�$�a��@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
mZddlmZddlmZddlmZddlmZmZdd	lmZmZdd
lmZddlmZddlm Z gd
�Z!d3dede"de#ddfdd�Z$d3dede"de#ddfdd�Z%de"de"ddfdd�Z&d4dede
de"de
ddf
dd �Z'd!e"de
fd"d#�Z(Gd$d%�d%�Z)Gd&d'�d'ej*�Z+Gd(d)�d)�Z,e�-d*�Z.d5d+e"d,e/dee"ddffd-d.�Z0de"de"fd/d0�Z1d1d2�Z2dS)6z�
    sphinx.testing.util
    ~~~~~~~~~~~~~~~~~~~

    Sphinx test suite utilities

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�StringIO)�IO�Any�Dict�	Generator�List�Pattern)�ElementTree)�nodes)�Node)�
directives�roles)�application�locale)�ModuleAnalyzer��path)�relpath)�Struct�
SphinxTestApp�#SphinxTestAppWrapperForSkipBuilding�regex�text�flags�returncCs"t�|||�sJd||f��dS)NFz%r did not match %r��re�search�rrr�r�5/usr/lib/python3/dist-packages/sphinx/testing/util.py�assert_re_search!��r!cCs"t�|||�rJd||f��dS)NFz%r did match %rrrrrr �assert_not_re_search&r"r#�thing�prefixcCs|�|�s
Jd||f��dS)NFz%r does not start with %r��
startswith)r$r%rrr �assert_startswith+s
�r(��node�cls�xpath�kwargsc	Ks�|r�t|t�r_t||dfd|i|��|dd�r^t|dt�r/t||dfd|i|��n�t|tj�s;Jd|��t|�dksKJd|t|�f��t|d|dd�fd|di|��nft|t�r�t|ttjf�srJd|��t|�t|�ks�Jd|t|�t|�f��t|�D]\}}|d	|}t|||fd|i|��q�n!t|t�r�||ks�Jd
|||f��nt||�s�Jd|||f��|r�t|tj�s�Jd|��|�	�D]%\}}||vs�Jd
|||f��|||ks�Jd|||||f��q�dSdS)Nrr,�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]zThe node %r is not %r: %rz$The node%s is not subclass of %r: %rz'The node%s does not have any attributesz)The node%s does not have %r attribute: %rzThe node%s[%s] is not %r: %r)
�
isinstance�list�assert_node�tupler
�Element�len�	enumerate�str�items)	r*r+r,r-�i�nodeclsr�key�valuerrr r10sV
��&�
���
��
���r1rcCsHtjdd��tjdtd�t�|�Wd�S1swYdS)NF)�record�ignore)�category)�warnings�catch_warnings�filterwarnings�DeprecationWarningr	�parserrrr �etree_parseVs$�rDc@seZdZdeddfdd�ZdS)rr-rNcKs|j�|�dS�N)�__dict__�update)�selfr-rrr �__init__]szStruct.__init__)�__name__�
__module__�__qualname__rrIrrrr r\srcs�eZdZUdZdZeed<dZeed<				dded	e	d
e	de
ded
edede
edededdf�fdd�
Zdde
ddfdd�Zdefdd�Z�ZS)rz�
    A subclass of :class:`Sphinx` that runs on the test root, with some
    better default values for the initialization parameters.
    N�_status�_warning�htmlFr�buildername�srcdir�builddir�freshenv�
confoverrides�status�warning�tags�docutilsconf�parallelrcs�|	dur|d�|	�|dur|d}|}|�|�}|jdd�|�d�}
|
jdd�|dur1i}d}tjdd�|_tj��|_	t
j��|_dd�t
tj�D�|_zt�j||||
||||||||
d	�WdStys|���w)
Nz
docutils.conf�_buildT)�exist_ok�doctreesFcSsh|]	}|�d�r|�qS)�visit_r&)�.0�vrrr �	<setcomp>�s
�z)SphinxTestApp.__init__.<locals>.<setcomp>)rY)�
write_text�joinpath�makedirs�sysr�_saved_pathr�_directives�copy�_saved_directivesr
�_roles�_saved_roles�dirr
�GenericNodeVisitor�_saved_nodeclasses�superrI�	Exception�cleanup)rHrPrQrRrSrTrUrVrWrXrY�confdir�outdir�
doctreedir�warningiserror��	__class__rr rIis2

��zSphinxTestApp.__init__r\cCs�tj��tj��|jtjdd�<tj�	dd�|j
t_|j
t_ttj�D]$}|�d�rJ||jvrJttjd|dd��ttjd|dd��q&dS)N�autodoc_fodderr]��depart_)r�cache�clearr�translatorsrerdr�modules�poprhrrfrjr
rirkr
rlr'rm�delattr)rHr\�methodrrr rp�s



��zSphinxTestApp.cleanupcCsd|jj|jjfS)Nz<%s buildername=%r>)rvrJ�builder�name)rHrrr �__repr__�szSphinxTestApp.__repr__)
rONNFNNNNNr)F)rJrKrL�__doc__rMr�__annotations__rNr6r�boolrrr�intrIrpr��
__classcell__rrrur ras6
���������#
rc@sJeZdZdZdeddfdd�Zdedefdd	�Zd
ededdfdd
�Z	dS)rz�
    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_rNcCs
||_dSrE)�app)rHr�rrr rI�s
z,SphinxTestAppWrapperForSkipBuilding.__init__r�cCst|j|�SrE)�getattrr�)rHr�rrr �__getattr__�sz/SphinxTestAppWrapperForSkipBuilding.__getattr__�argsr-cOs&|jj��s|jj|i|��dSdSrE)r�rr�listdir�build)rHr�r-rrr r��s�z)SphinxTestAppWrapperForSkipBuilding.build)
rJrKrLr�rrIr6rr�r�rrrr r�s
rzu(".*?")|u(\'.*?\')�root�suffixc#sT�tj|dd�D]\}}}t|�}�fdd�|D�D]}||}t||�VqqdS)NT)�followlinkscsg|]}�r|���r|�qSr)�endswith)r^�f�r�rr �
<listcomp>�szfind_files.<locals>.<listcomp>)�os�walkrr)r�r��dirpath�dirs�filesr��fpathrr�r �
find_files�s���r�cCst�dd|�S)Nz.*?mr))r�sub)rrrr �strip_escseq�sr�cst����fdd��}|S)zA
    A simple decorator that does nothing, for tests to use.
    cs�|i|��SrEr)r�r-�r�rr �wrapper�sz!simple_decorator.<locals>.wrapper)�	functools�wraps)r�r�rr�r �simple_decorator�sr�)r)Nr)rE)3r�r�r�rrdr?�ior�typingrrrrrr�	xml.etreer	�docutilsr
�docutils.nodesr�docutils.parsers.rstrr
�sphinxrr�
sphinx.pycoder�sphinx.testing.pathr�sphinx.util.osutilr�__all__r6r�r!r#r(r1rDr�Sphinxrr�compile�_unicode_literals_rer�r�r�r�rrrr �<module>s:	  &<
"