U
    nuf                     @   s*  U d dl Z d dlZd dlmZ d dlmZmZ dadd Zz8e j	dkrLe
n$d dlmZmZ d d	lmZ d
d ZW n" e
k
r   G dd dZY nX e Ze Ze ZdZdZdZdZeeeegdf  ed< d ae add Zdd Zed!ddZddddZddddZdd Z dd  Z!dS )"    N)contextmanager)CallableOptionalFc                   C   s   dS )z
    Lazily init colorama if necessary, not to screw up stdout if debugging is
    not enabled.

    This version of the function does nothing.
    N r   r   r   ./tmp/pip-unpacked-wheel-ol4ehs9f/jedi/debug.py_lazy_colorama_init	   s    r   nt)Foreinit)
initialisec                   C   s6   t s.dt_ztdd W n tk
r,   Y nX da dS )z
            Lazily init colorama if necessary, not to screw up stdout is
            debug not enabled.

            This version of the function does init colorama.
            TF)stripN)_initedr   atexit_doner
   	Exceptionr   r   r   r   r      s    c                   @   s$   e Zd ZdZdZdZdZdZdZdS )r	    N)	__name__
__module____qualname__REDGREENYELLOWMAGENTARESETBLUEr   r   r   r   r	   1   s   r	   debug_functionc                   C   s   t   adad S )Nr   )time_start_time_debug_indentr   r   r   r   
reset_timeG   s    r   c                    s    fdd}|S )zDecorator for makin c               
      s(   t    | |W  5 Q R  S Q R X d S N)increase_indent_cm)argskwargsfuncr   r   wrapperO   s    z increase_indent.<locals>.wrapperr   )r$   r%   r   r#   r   increase_indentM   s    r&   r   c              
   c   sJ   | rt d|  |d td7 az
d V  W 5 td8 a| rDt d|  |d X d S )NzStart: color   zEnd: )dbgr   )titler(   r   r   r   r    U   s    
r    r   r'   c                G   sF   |st trBtrBdt }t  t||d | tdd |D    dS )zB Looks at the stack, to see if a debug message should be printed.  zdbg: c                 s   s   | ]}t |V  qd S r   repr.0ar   r   r   	<genexpr>j   s     zdbg.<locals>.<genexpr>N)AssertionErrorr   enable_noticer   r   tuple)messager(   r!   ir   r   r   r*   c   s
    r*   T)formatc                G   s@   t r<tr<dt }|r*| tdd |D  } t d|d |   d S )Nr,   c                 s   s   | ]}t |V  qd S r   r-   r/   r   r   r   r2   q   s     zwarning.<locals>.<genexpr>r   z	warning: )r   enable_warningr   r5   )r6   r8   r!   r7   r   r   r   warningm   s
    r:   c                 C   s:   t r6tr6t }dt }t d|d d| |t f   d S )Nr,   r   zspeed: z%s %s)r   enable_speedr   r   r   )namenowr7   r   r   r   speedu   s    r>   c                 C   s&   t t| }t  t|| tj  dS )z
    The default debug function that prints to standard out.

    :param str color: A string that is an attribute of ``colorama.Fore``.
    N)getattrr	   r   printr   )r(   Zstr_outcolr   r   r   print_to_stdout|   s    
rB   )Nr   )"osr   
contextlibr   typingr   r   r   r   r<   ImportErrorcoloramar	   r
   r   objectZNOTICEWARNINGZSPEEDr;   r9   r4   r   str__annotations__r   r   r   r&   r    r*   r:   r>   rB   r   r   r   r   <module>   s>    	

