o
    by                  
   @   s8  d Z ddlZddlmZmZ ddlmZ ddlZddlm	Z	m
Z
 d$dee ded	ed
dfddZd$dee ded	ed
dfddZd$dee ded	ed
dfddZd$dee ded	ed
dfddZdedededed
ef
ddZdedededed
ef
ddZded
efddZeddddd ed!ed
efd"d#ZdS )%zMNice output for Black.

The double calls are for patching purposes in tests.
    N)AnyOptional)
mypyc_attr)echostyleTmessagenlstylesreturnc                 K   s:   | d urd|vrd|d< t | fi |} t| |dd d S )NboldTr   errr   r   r   r   r	    r   K/var/www/secure340b-portal/env/lib/python3.10/site-packages/black/output.py_out   
   r   c                 K   s:   | d urd|vrd|d< t | fi |} t| |dd d S )NfgredTr   r   r   r   r   r   _err   r   r   c                 K      t | fd|i| d S Nr   )r   r   r   r   r   out      r   c                 K   r   r   )r   r   r   r   r   r   "   r   r   aba_nameb_namec                    s>   t | t | fddtd D }d|S )zHReturn a unified diff string between each cell in notebooks `a` and `b`.c              	      sj   g | ]1\}}|d  dkrt dd | d d dd | d d   d|  d| qS )Z	cell_typecode cellssource
z:cell_)diffjoin).0Zcell_numbercellr   Za_nbr   Zb_nbr   r   
<listcomp>*   s    
zipynb_diff.<locals>.<listcomp>r!   r    )jsonloads	enumerater%   )r   r   r   r   
diff_linesr   r(   r   
ipynb_diff&   s   




r.   c           	      C   s   ddl }dd | jddD }dd |jddD }g }|j||||dd	D ]}|d
 dkr4|| q&||d  |d q&d|S )z9Return a unified diff string between strings `a` and `b`.r   Nc                 S      g | ]}|qS r   r   r&   liner   r   r   r)   ;       zdiff.<locals>.<listcomp>T)keependsc                 S   r/   r   r   r0   r   r   r   r)   <   r2      )fromfiletofilenr#   z\ No newline at end of file
r    )difflib
splitlinesZunified_diffappendr%   )	r   r   r   r   r9   Za_linesZb_linesr-   r1   r   r   r   r$   7   s   


r$   contentsc                 C   s   |  d}t|D ]<\}}|ds|drd| d }n#|dr*d| d }n|dr6d	| d }n|d
rAd| d }|||< q	d|S )z(Inject the ANSI color codes to the diff.r#   z+++z---z[1;37mz[0mz@@z[36m+z[32m-z[31m)splitr,   
startswithr%   )r<   linesir1   r   r   r   
color_diffL   s   





rC   )Z	patchable)ensure_final_newlineoutputrD   c                 G   sp   t jdddddd#}|D ]}|| | r#|r#|d dkr#|d qW d	   |jS 1 s0w   Y  |jS )
z;Dump `output` to a temporary file. Return path to the file.wZblk_z.logFutf8)modeprefixsuffixdeleteencodingr8   r#   N)tempfileNamedTemporaryFilewritename)rD   rE   frA   r   r   r   dump_to_file\   s   



rR   )NT)__doc__r*   typingr   r   Zmypy_extensionsr   rM   Zclickr   r   strboolr   r   r   r   r.   r$   rC   rR   r   r   r   r   <module>   s        "