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/directives/__pycache__/code.cpython-310.pyc
o

�$�a�G�
@s�dZddlZddlZddlmZddlmZmZmZm	Z	m
Z
ddlmZddl
mZmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZmZddlm Z ddl!m"Z"erlddl#m$Z$e�%e&�Z'Gdd�de �Z(d(de	e)de*de
e)e*fde	e)fdd�Z+de dede)dej,fdd�Z-Gdd�de �Z.Gd d!�d!�Z/Gd"d#�d#e �Z0d$d%dee)effd&d'�Z1dS))z�
    sphinx.directives.code
    ~~~~~~~~~~~~~~~~~~~~~~

    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�unified_diff)�
TYPE_CHECKING�Any�Dict�List�Tuple)�nodes)�Element�Node)�
directives)�
StringList)�addnodes)�Config)�optional_int)�__)�logging�parselinenos)�SphinxDirective)�
OptionSpec)�Sphinxc@sJeZdZUdZdZdZdZdZej	ej
d�Zee
d<deefdd	�Zd
S)�	Highlightzt
    Directive to set the highlighting language for code blocks, as well
    as the threshold for line numbers.
    F�r)�force�linenothreshold�option_spec�returncCsF|jd��}|j�dtj�}d|jv}||jjd<tj	|||d�gS)Nrrr�highlight_language)�langrr)
�	arguments�strip�options�get�sys�maxsize�env�	temp_datar
�
highlightlang)�self�languagerr�r)�8/usr/lib/python3/dist-packages/sphinx/directives/code.py�run0s
�z
Highlight.runN)�__name__�
__module__�__qualname__�__doc__�has_content�required_arguments�optional_arguments�final_argument_whitespacer�flag�positive_intrr�__annotations__rr
r+r)r)r)r*r!s
�r�lines�dedent�locationrcs|�s
t�d�|���d�St�fdd�|D��r!tjtd�|d�g}|D]}|�d�}|�d�r6|s6d}|�	|�q%|S)N�Tc3s �|]}|d����VqdS�N)r)�.0�s�r8r)r*�	<genexpr>?��zdedent_lines.<locals>.<genexpr>z!non-whitespace stripped by dedent�r9�
)
�textwrapr8�join�
splitlines�any�logger�warningr�endswith�append)r7r8r9�	new_lines�line�new_liner)r>r*�dedent_lines;srN�	directive�literal_node�captioncCs�tjdddgd�}t��}|j�t|gdd�|j|�t|dtj�r1t	d|d�
��}t|��t|dtj�r[tj|dj
dg|dj�R�}|j|_|j|_||7}||7}|St�)Nr:Tzliteral-block-wrapper)�
literal_block�classes��sourcerzInvalid caption: %s)r�	containerr	�state�nested_parser�content_offset�
isinstance�system_messager�astext�
ValueErrorrQ�	rawsource�childrenrUrL�RuntimeError)rOrPrQ�container_node�parsed�msg�caption_noder)r)r*�container_wrapperLs(���rec	@s^eZdZUdZdZdZdZdZej	ej	e
eejejej
ejd�Zeed<deefd	d
�ZdS)�	CodeBlockz^
    Directive for a code block with special highlighting or line numbering
    settings.
    TrrF)r�linenosr8�lineno-start�emphasize-linesrQ�class�namerrc
s:|jj}d�|j�}|j�|j�}|j�d�}|rfz0t	|j��t
|��}t�fdd�|D��r?tj
td��|jdf|d��fdd�|D�}Wntye}z|jj
||jd	�gWYd}~Sd}~wwd}d
|jvr�|j�|j�}|�d�}t||jd
|d�}d�|�}t�||�}d|jvs�d|jvr�d
|d<|d|j�dg�7<d|jv|d<|jr�|jd|d<n|jj�d|jj�|d<i}	|d<|dur�||	d<d|jvr�|jd|	d<|�|�|j�d�}
|
�rzt|||
�}Wnt�y}z|jj
||jd	�gWYd}~Sd}~ww|�|�|gS)NrBric3��|]}|�kVqdSr;r)�r<�i��nlinesr)r*r?���z CodeBlock.run.<locals>.<genexpr>�*line number spec is out of range(1-%d): %rrAc�g|]
}|�kr|d�qS�rr)�r<�xror)r*�
<listcomp>��z!CodeBlock.run.<locals>.<listcomp>�rLr8rgrhTrSrjrrr(r�highlight_args�hl_lines�linenostartrQ)rW�documentrD�content�
state_machine�get_source_and_line�linenor r!�lenrrFrGrHrr]�reporter�splitrNrrRrr$r%�configr�set_source_infore�add_name)r'r}�coder9�linespecr{�errr7�literal�
extra_argsrQ�excr)ror*r+vsf


�� ��



�

 ��
z
CodeBlock.runN)r,r-r.r/r0r1r2r3rr4r�int�unchanged_required�class_option�	unchangedrrr6rr
r+r)r)r)r*rfas 
�rfc@s�eZdZgd�Zdedededdfdd�Zd!d	d
�Zd"dede	ee
fdeefdd
�Zd"de	ee
fde	ee
ffdd�Z
d"de	ee
fdeefdd�Zd"deede	ee
fdeefdd�Zd"deede	ee
fdeefdd�Zd"deede	ee
fdeefdd�Zd"deede	ee
fdeefdd�Zd"deede	ee
fdeefdd�Zd"deede	ee
fdeefdd�Zd"deede	ee
fdeefdd �ZdS)#�LiteralIncludeReader)
)�lineno-matchrh)r�rJ)r��prepend)�start-after�start-at)�
end-before�end-at)�diff�pyobject)r�rh)r�r�)r�r7)r�r�)r�r�)r�r�)r�r��filenamer r�rNcCs8||_||_|�d|j�|_|j�dd�|_|��dS)N�encodingrhr)r�r r!�source_encodingr��lineno_start�
parse_options)r'r�r r�r)r)r*�__init__�s
zLiteralIncludeReader.__init__cCs<|jD]\}}||jvr||jvrttd�||f��qdS)Nz%Cannot use both "%s" and "%s" options)�INVALID_OPTIONS_PAIRr r]r)r'�option1�option2r)r)r*r��s���z"LiteralIncludeReader.parse_optionsr9c
Cs�z2t||jdd��}|��}d|jvr|�|jd�}|�d�Wd�WS1s+wYWdStyG}z	ttd�|�|�d}~wty^}zttd�|j|f�|�d}~ww)N�strict)r��errors�	tab-widthTz.Include file %r not found or reading it failedz`Encoding %r used for reading included file %r seems to be wrong, try giving an :encoding: option)	�openr��readr �
expandtabsrE�OSErrorr�UnicodeError)r'r�r9�f�textr�r)r)r*�	read_file�s,
(��������zLiteralIncludeReader.read_filecCsld|jvr
|��}n#|j|j|j|j|j|j|jg}|j	|j
|d�}|D]}|||d�}q$d�|�t|�fS)Nr�rAr:)
r �	show_diff�pyobject_filter�start_filter�
end_filter�lines_filter�prepend_filter�
append_filter�
dedent_filterr�r�rDr�)r'r9r7�filters�funcr)r)r*r��s

�zLiteralIncludeReader.readcCs:|�|j�}|j�d�}|�|�}t||||j�}t|�S)Nr�)r�r�r r!r�list)r'r9rK�old_filename�	old_linesr�r)r)r*r��s

zLiteralIncludeReader.show_diffr7c	Cs�|j�d�}|rDddlm}|�|jd�}|��}||vr(ttd�||jf��||d}||d}||d|�}d|jvrD||_	|S)	Nr�r)�ModuleAnalyzerr:z,Object named %r not found in include file %rr�r�)
r r!�
sphinx.pycoder��for_filer��	find_tagsr]rr�)	r'r7r9r�r��analyzer�tags�start�endr)r)r*r��s�
z$LiteralIncludeReader.pyobject_filtercs�|j�d�}|rgt|t���}t�fdd�|D��r)tjtd�t��|f|d�d|jvrO|d�t�fdd�t	|�D��rI|j
|d7_
nttd	����fd
d�|D���gkrgttd�||jf���S)
Nr7c3s�|]	}|t��kVqdSr;�r�rm�r7r)r*r?s�z4LiteralIncludeReader.lines_filter.<locals>.<genexpr>rrrAr�rc3s �|]\}}�||kVqdSr;r))r<rn�n)�firstr)r*r?r@z8Cannot use "lineno-match" with a disjoint set of "lines"cs g|]}|t��kr�|�qSr)r�)r<r�r�r)r*rws z5LiteralIncludeReader.lines_filter.<locals>.<listcomp>z2Line spec %r: no lines pulled from include file %r)
r r!rr�rFrGrHr�all�	enumerater�r]r�)r'r7r9r��linelistr))r�r7r*r�
s(

��
�z!LiteralIncludeReader.lines_filtercCs�d|jvr|j�d�}d}nd|jvr|j�d�}d}nd}|rkt|�D]6\}}||vrZ|rFd|jvr<|j|d7_||dd�Sd|jvrR|j|7_||d�Sq$|duretd|��td|��|S)	Nr�Fr�Tr�rz!start-after pattern not found: %szstart-at pattern not found: %s)r r!r�r�r])r'r7r9r��	inclusiver�rLr)r)r*r�%s,



�z!LiteralIncludeReader.start_filtercCs�d|jvr|j�d�}d}nd|jvr|j�d�}d}nd}|rVt|�D]!\}}||vrE|r8|d|d�S|dkr=q$|d|�Sq$|durPtd|��td|��|S)	Nr�Tr�Frrzend-at pattern not found: %sz end-before pattern not found: %s)r r!r�r])r'r7r9r�r�r�rLr)r)r*r�Ds(

�zLiteralIncludeReader.end_filtercCs$|j�d�}|r|�d|d�|S)Nr�rrB)r r!�insert)r'r7r9r�r)r)r*r�_sz#LiteralIncludeReader.prepend_filtercCs"|j�d�}|r|�|d�|S)NrJrB)r r!rJ)r'r7r9rJr)r)r*r�fsz"LiteralIncludeReader.append_filtercCs$d|jvrt||j�d�|d�S|S)Nr8rA)r rNr!)r'r7r9r)r)r*r�ms
z"LiteralIncludeReader.dedent_filter)rNr;)r,r-r.r��strrrr�r�rr�rr�r�r�r�r�r�r�r�r�r�r)r)r)r*r��s
$$ ((((((,r�c@s�eZdZUdZdZdZdZdZide�de	j
�de�d	e	j
�d
e�de	j�de	j
�d
e	j
�de	j�de	j�de	j�de	j�de	j�de	j�de	j�de	j�de	j�e	je	je	je	jd��Zeed<deefdd�ZdS)�LiteralIncludez�
    Like ``.. include:: :literal:``, but only warns if the include file is
    not found, and does not raise errors.  Also has several options for
    selecting what to include.
    FrrTr8rgrhr�r�r(rr�r�r7r�r�r�r�r�rJri)rQrjrkr�rrc
s(|jj}|jjs|jjd|jd�gSd|jvr'|j�	|jd�\}}||jd<z�|j
�|j�}|j�	|jd�\}}|j�
|�t||j|j�}|j|d�\}�tj|||d�}	d|jv|	d<|�|	�|j�d�rod|	d	<nd	|jvr{|jd	|	d	<d
|jvs�d|jvs�d|jvr�d
|	d
<|	d|j�dg�7<i}
|	d<d|jvr�t|jd��}t�fdd�|D��r�tjtd��|jdf|d��fdd�|D�|
d<|j|
d<d|jvr�|jdp�|jd}t||	|�}	|�|	�|	gWSt�y}
z|jj|
|jd�gWYd}
~
Sd}
~
ww)NzFile insertion disabledryr�rrArTr�udiffr(rgrhr�TrSrjrzric3rlr;r)rmr�r)r*r?�rqz%LiteralInclude.run.<locals>.<genexpr>rrcrsrtr)rur�r)r*rw�rxz&LiteralInclude.run.<locals>.<listcomp>r{r|rQ)rWr}�settings�file_insertion_enabledr�rHr�r r$�
relfn2pathrr�r�note_dependencyr�r�r�rrRr�r!rrFrGrr�rer��	Exception)r'r}�_�pathr9�rel_filenamer��readerr��retnoder�r{rQr�r)r�r*r+�sZ�







��


 ��zLiteralInclude.runN)r,r-r.r/r0r1r2r3rrr4r�r�r�r�r�rrr6rr
r+r)r)r)r*r�ts^
��������	�
���
������r��apprcCs<t�dt�t�dt�t�dt�t�dt�dddd�S)N�	highlightz
code-block�
sourcecode�literalinclude�builtinT)�version�parallel_read_safe�parallel_write_safe)r�register_directiverrfr�)r�r)r)r*�setup�s�r�r;)2r/r"rC�difflibr�typingrrrrr�docutilsr�docutils.nodesr	r
�docutils.parsers.rstr�docutils.statemachiner�sphinxr
�
sphinx.configr�sphinx.directivesr�
sphinx.localer�sphinx.utilrr�sphinx.util.docutilsr�sphinx.util.typingr�sphinx.applicationr�	getLoggerr,rGrr�r�rNrVrerfr�r�r�r)r)r)r*�<module>s6
,SAW