o
    Ni                     @  s  U 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mZ erddlm	Z	 dgd	d
Z
dgddZdgddZdgddZdgddZdgddZdgddZdgddZdgddZdgddZdgddZdgdd Zdgd!d"Zdgd#d$Zdgd%d&Zdgd'd(Zdgd)d*Zdgd+d,Zdgd-d.Zdgd/d0Zdgd1d2Zdgd3d4Zzddl Z d5Z!W n e"y   d6Z!Y nw e#d7Z$d8e%d9< e&d:Z'd;e%d<< e&e$d= ej(ej)B Z*d;e%d>< 	 i Z+d?e%d@< dhdBdCZ,didEdFZ-e- Z.dDe%dG< dgdHdIZ/djdKdLZ0dkdNdOZ1dkdPdQZ2dldmdTdUZ3dhdVdWZ4dgdXdYZ5dndZd[Z6d\d]d^d_d`dadbZ7e78 D ]\Z9Z:d7e: e+e9< qg dcZ;e<e;ddD ]\Z=\Z>Z?dee= e+e>< dee=df  e+e?< q.e+@ ZAe+D ]ZBe6eB qJdS )ozFormat colored console output.    )annotationsN)TYPE_CHECKING)Finaltextstrreturnc                 C     d S N r   r
   r
   G/home/ubuntu/.local/lib/python3.10/site-packages/sphinx/util/console.pyreset       r   c                 C  r   r	   r
   r   r
   r
   r   bold   r   r   c                 C  r   r	   r
   r   r
   r
   r   faint   r   r   c                 C  r   r	   r
   r   r
   r
   r   standout   r   r   c                 C  r   r	   r
   r   r
   r
   r   	underline   r   r   c                 C  r   r	   r
   r   r
   r
   r   blink   r   r   c                 C  r   r	   r
   r   r
   r
   r   black   r   r   c                 C  r   r	   r
   r   r
   r
   r   white   r   r   c                 C  r   r	   r
   r   r
   r
   r   red   r   r   c                 C  r   r	   r
   r   r
   r
   r   green   r   r   c                 C  r   r	   r
   r   r
   r
   r   yellow   r   r   c                 C  r   r	   r
   r   r
   r
   r   blue   r   r   c                 C  r   r	   r
   r   r
   r
   r   fuchsia   r   r   c                 C  r   r	   r
   r   r
   r
   r   teal   r   r   c                 C  r   r	   r
   r   r
   r
   r   darkgray   r   r   c                 C  r   r	   r
   r   r
   r
   r   	lightgray    r   r   c                 C  r   r	   r
   r   r
   r
   r   darkred!   r   r   c                 C  r   r	   r
   r   r
   r
   r   	darkgreen"   r   r   c                 C  r   r	   r
   r   r
   r
   r   brown#   r   r    c                 C  r   r	   r
   r   r
   r
   r   darkblue$   r   r!   c                 C  r   r	   r
   r   r
   r
   r   purple%   r   r"   c                 C  r   r	   r
   r   r
   r
   r   	turquoise&   r   r#   TFz[z
Final[str]_CSIz\x1b\[(?:\d+;){0,2}\d*mzFinal[re.Pattern[str]]_ansi_color_rez
    (?:
      (?:\d+;){0,2}\d*m     # ANSI color code    ('m' is equivalent to '0m')
    |
      [012]?K               # ANSI Erase in Line ('K' is equivalent to '0K')
    )_ansi_rezdict[str, str]codessc                 C  s   |  dddS )z4Safely encode a string for printing to the terminal.asciibackslashreplace)encodedecoder(   r
   r
   r   terminal_safeH   s   r.   intc                   C  s   t  jd S )z,Return the width of the terminal in columns.   )shutilget_terminal_sizecolumnsr
   r
   r
   r   get_terminal_widthM   s   r4   _twc                 C  s.   t s| d S | tt|  tt|  d S )N
)r'   ljustr5   lenstrip_escape_sequencesr   r
   r
   r   term_width_lineU   s   "r;   boolc                  C  s   dt jv rdS tjdkrtrt  dS dt jv rdS ttjds#dS tj	 s*dS dt jv r1dS t j
dd	 } | d
v pAd| v S )NNO_COLORFwin32TFORCE_COLORisatty	COLORTERMTERMdumb)xtermlinuxcolor)osenvironsysplatformCOLORAMA_AVAILABLEcoloramajust_fix_windows_consolehasattrstdoutr@   getlower)termr
   r
   r   color_terminal^   s   



rS   Nonec                   C  s"   t jdkrtrt  t  d S )Nr>   )rI   rJ   rK   rL   deinitr'   clearr
   r
   r
   r   nocolorp   s   rW   c                   C  s   t t d S r	   )r'   update_orig_codesr
   r
   r
   r   coloronv   s   rZ   name
input_modec                   s"   d fdd}|| | |d S )Nr[   r   r   c                   s.   t | d} r|rtjdkrd| d S |S )N r>   )r'   rP   rI   rJ   )r[   escaper\   r
   r   escseq{   s   zcolorize.<locals>.escseqr   )r[   r   r   r   r
   )r[   r   r\   rb   r
   ra   r   colorizez   s   rc   c                 C     t d| S )zRemove the ANSI color codes in a string *s*.

    .. caution::

       This function is not meant to be used in production and should only
       be used for testing Sphinx's output messages.

    .. seealso:: :func:`strip_escape_sequences`
    r]   )r%   subr-   r
   r
   r   strip_colors   s   
rf   c                C  rd   )a  Remove the ANSI CSI colors and "erase in line" sequences.

    Other `escape sequences `__ (e.g., VT100-specific functions) are not
    supported and only control sequences *natively* known to Sphinx (i.e.,
    colors declared in this module and "erase entire line" (``'\x1b[2K'``))
    are eliminated by this function.

    .. caution::

       This function is not meant to be used in production and should only
       be used for testing Sphinx's output messages that were not tempered
       with by third-party extensions.

    .. versionadded:: 7.3

       This function is added as an *experimental* feature.

    __ https://en.wikipedia.org/wiki/ANSI_escape_code
    r]   )r&   re   r   r
   r
   r   r:      s   r:   c                   s   d fdd}|t   < d S )Nr   r   r   c                   s
   t  | S r	   )rc   r   r[   r
   r   inner   s   
z create_color_func.<locals>.innerr   r   r   r   )globals)r[   rh   r
   rg   r   create_color_func   s   rk   z	39;49;00m01m02m03m04m05m)r   r   r   r   r   r   ))r   r   )r   r   )r   r   )r    r   )r!   r   )r"   r   )r#   r   )r   r      z[%im<   ri   )r(   r   r   r   )r   r/   )r   r<   )r   rT   )F)r[   r   r   r   r\   r<   r   r   )r[   r   r   rT   )C__doc__
__future__r   rG   rer1   rI   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   rL   rK   ImportErrorr`   r$   __annotations__compiler%   VERBOSEASCIIr&   r'   r.   r4   r5   r;   rS   rW   rZ   rc   rf   r:   rk   _attrsitems__name__value_colors	enumerate__i__dark__lightcopyrY   _namer
   r
   r
   r   <module>   s    



























	




	