
    !.d              
          d Z ddlZddlZddl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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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      ,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_linesr/   r0   s     `` @@r   
ipynb_diffr6   )   sy    :a==D:a==D	 	 	 	 	 	 	 "+4=!9!9	 	 	J 77:r   c                 h   ddl }|                     d          }|                    d          }g }|                    ||||d          D ]Q}|d         dk    r|                    |           $|                    |dz              |                    d	           Rd
                    |          S )z9Return a unified diff string between strings `a` and `b`.r   NT)keepends   )fromfiletofilenr)   z\ No newline at end of file
r&   )difflib
splitlinesunified_diffappendr+   )	r   r   r    r!   r>   a_linesb_linesr5   lines	            r   r*   r*   :   s    NNNllDl))GllDl))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)splitr4   
startswithr+   )rE   linesirD   s       r   
color_diffrM   O   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outputrN   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)rN   rO   frK   s       r   dump_to_filer^   _   s     
	$uv
 
 
 	
 	 	EGGENNN#  %)t2C2C	               6Ms   A A''A+.A+)NT)__doc__r2   rY   typingr   r   clickr   r   mypy_extensionsr   strboolr   r   r   r   r6   r*   rM   r^    r   r   <module>rf      s   
                           & & & & & & d# #(3- #D #3 #4 # # # # d# #(3- #D #3 #4 # # # # d# ## #4 ## #$ # # # ## ## #4 ## #$ # # # ## # s C C    "C C  c c    *       d<@ 	 	 	# 	T 	S 	 	 	 	 	 	r   