
    -Ph                    h   U d dl mZ d dlZd dlZd dlmZ d dlmZmZ er"d dl	m
Z
 d dlmZmZ d dlmZ  G d d	e          Z ej        d
          Zded<    ej        dej        ej        z            Zded<   d3dZd4dZddddd5d!Zd"d#d6d%Zd7d(Zddd)d8d*Zd9d,Zej        d"d"ddd-d:d2ZdS );    )annotationsN)TYPE_CHECKING)SphinxErrorSphinxParallelError)
Collection)FinalProtocol)	Extensionc                      e Zd ZddZdS )SupportsWritetextstrreturn
int | Nonec                   d S N )selfr   s     W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/_cli/util/errors.pywritezSupportsWrite.write   s          N)r   r   r   r   )__name__
__module____qualname__r   r   r   r   r   r      s        888888r   r   z[z
Final[str]_CSIz\[
    (?:
      (?:\d+;){0,2}\d*m  # ANSI color code    ('m' is equivalent to '0m')
    |
      [012]?K            # ANSI Erase in Line ('K' is equivalent to '0K')
    )zFinal[re.Pattern[str]]_ANSI_CODESsr   r   c               T    |                      dd                              d          S )z4Safely encode a string for printing to the terminal.asciibackslashreplace)encodedecode)r   s    r   terminal_safer#   $   s%    88G/0077@@@r   r   c               8    t                               d|           S )a  Remove the ANSI CSI colors and "erase in line" sequences.

    Other `escape sequences <https://en.wikipedia.org/wiki/ANSI_escape_code>`_
    (e.g., VT100-specific functions) are not supported. Only control sequences
    *natively* known to Sphinx (i.e., colour sequences used in Sphinx
    and "erase entire line" (``'\x1b[2K'``)) are stripped by this function.

    .. warning:: This function only for use within Sphinx..

    __ https://en.wikipedia.org/wiki/ANSI_escape_code
     )r   sub)r   s    r   strip_escape_sequencesr'   )   s     ??2t$$$r   r   Tmessage_log
extensionsfull_traceback	exceptionBaseExceptionr)   Collection[str]r*   Collection[Extension]r+   boolc                   d |D             }|r&|d         s|                                  |r|d         d                    |          }d                    d |D                       }t          | |           }t          |pd|pd|          S )z?Return a formatted message containing useful debugging context.c                V    g | ]&}d t          |                                           'S )    )r'   rstrip).0msgs     r   
<listcomp>z*full_exception_context.<locals>.<listcomp>@   s6    UUU#4-c2244;;==UUUr   
c              3  R   K   | ]"}|j         d k    d|j         d|j          dV  #dS )builtinz*  ()N)versionname)r5   exts     r   	<genexpr>z)full_exception_context.<locals>.<genexpr>D   sR        ;)## 	(SX'''''#### r   short_tracebackzNone.)popjoinformat_traceback
error_info)r,   r)   r*   r+   messages	last_msgs	exts_list
exc_formats           r   full_exception_contextrL   8   s     VUUUUH
 8B<   8B< 		(##I		      I
 ")=OPPPJi*7I,@*MMMr   FrB   rC   c                 |reddl m} |                    | d          }|j                                        d         d                    |                                          z   }nDt          | t                    rd| j          }n$ddl m	} d                     ||                     }d                    d	 |
                                                                D                       S )
z'Format the given exception's traceback.r   )TracebackExceptionr8   )limitr%   z(Error in parallel process)
)format_exceptionr9   c              3      K   | ]	}d | V  
dS )r3   Nr   )r5   lines     r   rA   z#format_traceback.<locals>.<genexpr>]   s(      PPt]D]]PPPPPPr   )	tracebackrN   from_exceptionstackformatrE   format_exception_only
isinstancer   rP   r4   
splitlines)r,   rC   rN   terK   rP   s         r   rF   rF   M   s      :000000  ..y.CCX__&&r*RWWR5M5M5O5O-P-PP

	I2	3	3 :JY5HJJ

......WW--i8899
99PPz/@/@/B/B/M/M/O/OPPPPPPr   rH   rS   c                   ddl }ddl}ddl}ddl}ddl}dt
          j          d|                                  d|                                 d|                                 d|j         d|j	         d	|j	         d
|j	         d|  d| d| dS )zFFormat the traceback and extensions list with environment information.r   Nz'Versions
========

* Platform:         z; (z)
* Python version:   r<   z)
* Sphinx version:   z
* Docutils version: z
* Jinja2 version:   z
* Pygments version: z

Last Messages
=============

z'

Loaded Extensions
=================

z

Traceback
=========

r9   )
platformdocutilsjinja2pygmentssphinxsyspython_versionpython_implementation__display_version____version__)rH   r*   rS   r\   r]   r^   r_   r`   s           r   rG   rG   `   s   OOOOOOMMMOOOMMM \	  '/&7&7&9&9	 
 ,,.. 
 3;2P2P2R2R  /  )  '  )  
 & ' 0 1   r   r)   r*   c               H    t          | ||          }t          |          }|S )z9Save the given exception's traceback in a temporary file.)r,   r)   r*   )rL   write_temporary_file)r,   r)   r*   outputfilenames        r   save_tracebackrk      s5     $  F
 $F++HOr   contentc                    ddl }|                    ddddd          5 }|                    |            ddd           n# 1 swxY w Y   |j        S )	z:Write content to a temporary file and return the filename.r   Nwzutf-8z.logzsphinx-err-F)encodingsuffixprefixdelete)tempfileNamedTemporaryFiler   r?   )rl   rs   fs      r   rh   rh      s    OOO		$	$gf]5 
% 
 
 	
	              
 6Ms   AAA)stderruse_pdbprint_tracebackr)   r*   rv   rw   rx   Nonec                  ddl m} ddlm} ddlm ddlm} t          | |          rd S dfd
dfd}	              |s+t          | t                    r  |d                     d S t          | |          r |	 |d                     t          | t                    r |	| j         d           t          | t                    r |	 |d                     t          | t                    r= |	 |d                                     |d                      d                         t          | |||p|          }
 |
                         |r,ddlm}  |	 |d                      || j                   d S t%          | ||          }  |d                      |                           |d                       |d                     d S )Nr   )BdbQuit)SystemMessage)red)__valuesr   r   ry   c                      t          | di d S )Nfile)print)r   rv   s    r   	print_errz#handle_exception.<locals>.print_err   s    v#F#####r   c                 .     t          |             d S r   )map)r   r   r}   s    r   	print_redz#handle_exception.<locals>.print_red   s     	3sF##$$$$r   zInterrupted!zreStructuredText markup error!!zEncoding error!zRecursion error!zThis can happen with very large or deeply nested source files. You can carefully increase the default Python recursion limit of 1,000 in conf.py with e.g.:z1
    import sys
    sys.setrecursionlimit(1_500)
r(   )post_mortemzStarting debugger:rf   z%The full traceback has been saved in:zwTo report this error to the developers, please open an issue at <https://github.com/sphinx-doc/sphinx/issues/>. Thanks!ziPlease also report this if it was a user error, so that a better error message can be provided next time.)r   r   r   ry   )bdbr{   docutils.utilsr|   sphinx._cli.util.colourr}   sphinx.localer~   rX   KeyboardInterruptr   categoryUnicodeErrorRecursionErrorrL   pdbr   __traceback__rk   )r,   rv   rw   rx   r)   r*   r{   r|   r~   r   error_contextr   traceback_info_pathr   r}   s    `           @@r   handle_exceptionr      s9    ,,,,,,++++++      )W%% $ $ $ $ $ $% % % % % % % IKKK z)->?? 	""^$$%%%)]++ 8	""566777)[)) ,	Y'***+++)\** )	""&''((()^,, 
J	""'(()))		BA 	
 	
 	
 		HIIIIKKK*&1'	  M ImIKKK ######	"")**+++I+,,, ){z   Ibb899:::I!"""IKKKI
I	
 	
   I
E	
 	
    r   )r   r   r   r   )r   r   r   r   )
r,   r-   r)   r.   r*   r/   r+   r0   r   r   )r,   r-   rC   r0   r   r   )rH   r   r*   r   rS   r   r   r   )r,   r-   r)   r.   r*   r/   r   r   )rl   r   r   r   )r,   r-   rv   r   rw   r0   rx   r0   r)   r.   r*   r/   r   ry   ) 
__future__r   rera   typingr   sphinx.errorsr   r   collections.abcr   r   r	   sphinx.extensionr
   r   escaper   __annotations__compileVERBOSEASCIIr   r#   r'   rL   rF   rG   rk   rh   rv   r   r   r   r   <module>r      s6   " " " " " " " 				 



             : : : : : : : : 9******&&&&&&&&******9 9 9 9 9 9 9 9 29W%% % % % %
 '1bj	 J	' 	' 	 	 	 	A A A A
% % % %$ $&(*N N N N N N, =BQ Q Q Q Q Q&# # # #R $&(*	      	 	 	 	   J!#%(*W W W W W W W Wr   