
    yIfc              
          d 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	m
Z
 ddlmZ  ed          ddee         d	ed
eddfd            Z ed          ddee         d	ed
eddfd            Z ed          ddee         d	ed
eddfd            Zddee         d	ed
eddfdZdededededef
dZ ej        d          Zdedee         fdZdededededef
dZdedefdZ ed          dddededefd            ZdS ) zMNice output for Black.

The double calls are for patching purposes in tests.
    N)AnyListOptional)echostyle)
mypyc_attrT)	patchablemessagenlstylesreturnc                 Z    | d|vrd|d<   t          | fi |} t          | |d           d S )NboldTr   errr   r   r
   r   r   s      @/var/www/piapp/venv/lib/python3.11/site-packages/black/output.py_outr      sL    !F6N**6**RT""""""    c                 Z    | d|vrd|d<   t          | fi |} t          | |d           d S )NfgredTr   r   r   s      r   _errr      sL    v F4L**6**RT""""""r   c                 $    t          | fd|i| d S Nr   )r   r   s      r   outr   !   s#    ""R"6"""""r   c                 $    t          | fd|i| d S r   )r   r   s      r   r   r   &   s#    ""R"6"""""r   aba_nameb_namec                     t          j        |           t          j        |          fdt          d                   D             }d                    |          S )zHReturn a unified diff string between each cell in notebooks `a` and `b`.c           
         g | ]}\  }}|d          dk    t          d                    d         |         d                   dz   d                    d         |         d                   dz    d|  d|           ~S )	cell_typecode cellssource
z:cell_)diffjoin).0cell_numbercellr!   a_nbr"   b_nbs      r   
<listcomp>zipynb_diff.<locals>.<listcomp>.   s     	 	 	 K&& 	GGDM+.x899D@GGDM+.x899D@**[****[**		
 	
 '&&r   r(   r'   )jsonloads	enumerater,   )r   r    r!   r"   
diff_linesr0   r1   s     `` @@r   
ipynb_diffr7   *   sy    :a==D:a==D	 	 	 	 	 	 	 "+4=!9!9	 	 	J 77:r   z(.*?(?:\r\n|\n|\r|$))r)   c                     d t                               |           D             }|d         dk    r|                    d           |S )zSplit a string into lines ignoring form feed and other chars.

    This mimics how the Python parser splits source code.

    A simplified version of the function with the same name in Lib/ast.py
    c                     g | ]
}|d          S )r    )r-   matchs     r   r2   z%_splitlines_no_ff.<locals>.<listcomp>E   s    CCC5eAhCCCr   r'   )_line_patternfinditerpop)r)   results     r   _splitlines_no_ffrA   >   sI     DCM$:$:6$B$BCCCFbzR

2Mr   c                 L   ddl }t          |           }t          |          }g }|                    ||||d          D ]Q}|d         dk    r|                    |           $|                    |dz              |                    d           Rd                    |          S )	z9Return a unified diff string between strings `a` and `b`.r   N   )fromfiletofilenr<   r*   z\ No newline at end of file
r'   )difflibrA   unified_diffappendr,   )	r   r    r!   r"   rG   a_linesb_linesr6   lines	            r   r+   r+   K   s    NNN""G""GJ$$6&A %   
@ 
@ 8td####dTk***>????77:r   contentsc                    |                      d          }t          |          D ]\  }}|                    d          s|                    d          r	d|z   dz   }nY|                    d          r	d|z   dz   }n;|                    d          r	d	|z   dz   }n|                    d
          rd|z   dz   }|||<   d                    |          S )z(Inject the ANSI color codes to the diff.r*   z+++z---z[1mz[0mz@@z[36m+z[32m-z[31m)splitr5   
startswithr,   )rM   linesirL   s       r   
color_diffrU   `   s    NN4  EU## 	 	4??5!! 	1T__U%;%; 	1t#i/DD__T"" 	1$y0DD__S!! 	1$y0DD__S!! 	1$y0Da99Ur   )ensure_final_newlineoutputrV   c                     t          j        ddddd          5 }|D ]<}|                    |           | r#|r!|d         dk    r|                    d           =	 d	d	d	           n# 1 swxY w Y   |j        S )
z;Dump `output` to a temporary file. Return path to the file.wblk_z.logFutf8)modeprefixsuffixdeleteencodingr<   r*   N)tempfileNamedTemporaryFilewritename)rV   rW   frS   s       r   dump_to_filerf   p   s     
	$uv
 
 
 	
 	 	EGGENNN#  %)t2C2C	               6Ms   A A''A+.A+)NT)__doc__r3   rera   typingr   r   r   clickr   r   mypy_extensionsr   strboolr   r   r   r   r7   compiler=   rA   r+   rU   rf   r:   r   r   <module>ro      s   
  				  & & & & & & & & & &         & & & & & & d# #(3- #D #3 #4 # # # # d# #(3- #D #3 #4 # # # # d# ## #4 ## #$ # # # ## ## #4 ## #$ # # # ## # s C C    " 
344
c 
d3i 
 
 
 
C C  c c    *       d<@ 	 	 	# 	T 	S 	 	 	 	 	 	r   