B
    2*\a                 @   s   d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl	Z	G dd dZ
dd ZdZd	Zd
ZedZdZdZdZdd Zedkrd dlmZ eddd dS )    N)	calltip_w)HyperParserc               @   sX   e Zd ZdddZdd Zdd Zddd	Zd
d Zdd Zdd Z	dd Z
dd ZdS )CalltipNc             C   s0   |d krd | _ n|| _ |j| _d | _| j| _d S )N)editwintextactive_calltip_make_tk_calltip_window_calltip_window)selfr    r   :C:\ALexclude\prg\programme\Python37\Lib\idlelib\calltip.py__init__   s    zCalltip.__init__c             C   s
   d | _ d S )N)r	   )r
   r   r   r   close   s    zCalltip.closec             C   s   t | jS )N)r   ZCalltipWindowr   )r
   r   r   r   r       s    zCalltip._make_tk_calltip_windowc             C   s   | j r| j   d | _ d S )N)r   Zhidetip)r
   eventr   r   r   _remove_calltip_window$   s    
zCalltip._remove_calltip_windowc             C   s   |  d dS )NTbreak)open_calltip)r
   r   r   r   r   force_open_calltip_event)   s    
z Calltip.force_open_calltip_eventc             C   s   |  d d S )NF)r   )r
   r   r   r   r   try_open_calltip_event.   s    zCalltip.try_open_calltip_eventc             C   s   | j r| j jr| d d S )NF)r   Z	tipwindowr   )r
   r   r   r   r   refresh_calltip_event5   s    zCalltip.refresh_calltip_eventc             C   s   |    t| jd}|d}|s&d S ||d  | }|sDd S |sZ|ddkrZd S | |}|sld S |  | _	| j	
||d |d  d S )Ninsert(r      )r   r   r   Zget_surrounding_bracketsZ	set_indexZget_expressionfind	fetch_tipr	   r   Zshowtip)r
   Z	evalfuncsZhpZ	sur_paren
expressionargspecr   r   r   r   9   s     


zCalltip.open_calltipc             C   sR   y| j jjjj}W n tk
r*   d }Y nX |rB|dd|fi S tt|S d S )NexecZget_the_calltip)	r   flistZpyshellZinterprpccltAttributeErrorZ
remotecallget_argspec
get_entity)r
   r   r    r   r   r   r   L   s    

zCalltip.fetch_tip)N)N)__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r   r   r   r   r      s   
	
r   c             C   s>   | r:t j }|tj y
t| |S  tk
r8   d S X d S )N)sysmodulescopyupdate__main____dict__evalBaseException)r   	namespacer   r   r   r#   e   s    

r#   U      z    z(?<=\()\w*\,?\s*zSee source or doczinvalid method signaturez4
['/' marks preceding arguments as positional-only]
c       
   
   C   sr  d }}y
| j }W n tk
r&   |S X t|tjr8|n| }ytt|}W n8 tk
r } zt|}|	t
rvt
S W d d }~X Y nX d|kr|t7 }t|tr|dkrt}t|tkrtj|ttdn|r|gng }t|tjr|j}nt| dd}|rZxZ|dtd t D ]B}	|	 }	|	s(P t|	tkrJ|	d td  d }	||	 qW d|}|snt}|S )	N /z())subsequent_indent__doc__
   z...)__call__r.   
isinstancetypes
MethodTypestrinspectZ	signature
ValueError
startswith_invalid_method_argument_positionaltype_default_callable_argspeclen	_MAX_COLStextwrapwrap_INDENTr5   getattrsplit
_MAX_LINESstripappendjoin)
Zobr   defaultZob_callZfoberrmsglinesdocliner   r   r   r"   |   s@    	

*
r"   r+   )mainzidlelib.idle_test.test_calltip   )	verbosity)r=   rer'   rF   r:   Zidlelibr   Zidlelib.hyperparserr   r+   r   r#   rE   rK   rH   compileZ_first_paramrC   r@   rA   r"   r$   ZunittestrU   r   r   r   r   <module>   s(   S
4