B
    Khh{                 @   sz   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZ G dd deZG d	d
 d
eZeG dd dZdS )z 
Summarize Black runs to users.
    )	dataclass)Enum)Path)style)erroutc               @   s   e Zd ZdZdZdZdS )Changedr         N)__name__
__module____qualname__NOZCACHEDYES r   r   //tmp/pip-install-vv81h98y/black/black/report.pyr      s   r   c               @   s   e Zd ZdZdS )NothingChangedz3Raised when reformatted code is the same as source.N)r   r   r   __doc__r   r   r   r   r      s   r   c               @   s   e Zd ZU dZdZeed< dZeed< dZeed< dZ	eed< dZ
eed< dZeed	< dZeed
< eeddddZeeddddZeeddddZeedddZedddZdS )ReportzDProvides a reformatting counter. Can be rendered with `str(report)`.Fcheckdiffquietverboser   change_count
same_countfailure_countN)srcchangedreturnc             C   s   |t jkrL| js| jrdnd}| js*| js<t| d|  |  jd7  _n@| jr~|t jkrh| d}n
| d}t|dd |  j	d7  _	d	S )
zGIncrement the counter for successful reformatting. Write out a message.zwould reformatreformatted r	   z" already well formatted, good job.z( wasn't modified on disk since last run.F)boldN)
r   r   r   r   r   r   r   r   r   r   )selfr   r   r   msgr   r   r   done#   s    


zReport.done)r   messager   c             C   s&   t d| d|  |  jd7  _dS )zCIncrement the counter for failed reformatting. Write out a message.zerror: cannot format z: r	   N)r   r   )r"   r   r%   r   r   r   failed3   s    zReport.failed)pathr%   r   c             C   s    | j rt| d| dd d S )Nz
 ignored: F)r!   )r   r   )r"   r'   r%   r   r   r   path_ignored8   s    zReport.path_ignored)r   c             C   s   | j r
dS | jr| jrdS dS )a  Return the exit code that the app should use.

        This considers the current state of changed files and failures:
        - if there were any failures, return 123;
        - if any files were changed and --check is being used, return 1;
        - otherwise return 0.
        {   r	   r   )r   r   r   )r"   r   r   r   return_code<   s
    zReport.return_codec             C   s   | j s| jrd}d}d}nd}d}d}g }| jrr| jdkr>dnd	}|t| j d
| ddddt| dd  | jr| jdkrdnd	}|t| j d
| ddd|  | jr| jdkrdnd	}|t| j d
| d| dd d|d S )zcRender a color report of the current state.

        Use `click.unstyle` to remove colors.
        zwould be reformattedzwould be left unchangedzwould fail to reformatr   zleft unchangedzfailed to reformatr	   s z filer    TZblue)r!   fg)r!   )r-   Zredz, .)r   r   r   appendr   r   r   join)r"   r   Z	unchangedr&   reportr+   r   r   r   __str__O   s(    $$zReport.__str__)r   r   r   r   r   bool__annotations__r   r   r   r   intr   r   r   r   r$   strr&   r(   propertyr*   r2   r   r   r   r   r      s   
r   N)r   Zdataclassesr   enumr   Zpathlibr   Zclickr   Zblack.outputr   r   r   UserWarningr   r   r   r   r   r   <module>   s   