Your IP : 52.14.173.116


Current Path : /opt/alt/python34/lib64/python3.4/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/idlelib/__pycache__/AutoComplete.cpython-34.pyc

�
e f�#�@s�dZddlZddlZddlZddlmZejejdZe	dd�\Z
Zddlm
Z
ddlmZddlZejZejr�eej7ZnGd	d
�d
�Zedkr�ddlmZed
dd�ndS)z�AutoComplete.py - An IDLE extension for automatically completing names.

This extension can complete either attribute names of file names. It can pop
a window with all available names, for the user to select from.
�N)�idleConf�_��)�AutoCompleteWindow)�HyperParserc@s�eZdZdd!gfgZejddddddd	�Zd
dd�Zd
d�Zd
dd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd
dd�Zdd�Zdd �Zd
S)"�AutoCompleteZedit�Show Completions�<<force-open-completions>>�
extensions�	popupwait�type�int�defaultrNcCsD||_|dkrdS|j|_d|_d|_d|_dS)N)�editwin�text�autocompletewindow�_delayed_completion_id�_delayed_completion_index)�selfr�r�9/opt/alt/python34/lib64/python3.4/idlelib/AutoComplete.py�__init__&s			zAutoComplete.__init__cCstj|j�S)N)rr)rrrr�_make_autocomplete_window3sz&AutoComplete._make_autocomplete_windowcCs&|jr"|jj�d|_ndS)N)rZhide_window)r�eventrrr�_remove_autocomplete_window6s	
z(AutoComplete._remove_autocomplete_windowcCs|jddd�dS)zqHappens when the user really wants to open a completion list, even
        if a function call is needed.
        TFN)�open_completions)rrrrr�force_open_completions_event;sz)AutoComplete.force_open_completions_eventcCs`|jjd�}|dkr7|jdddt�n%|tkr\|jdddt�ndS)z�Happens when it would be nice to open a completion list, but not
        really necessary, for example after an dot, so function
        calls won't be made.
        z	insert-1c�.FN)r�get�_open_completions_later�COMPLETE_ATTRIBUTES�SEPS�COMPLETE_FILES)rrZlastcharrrr�try_open_completions_eventAs
z'AutoComplete.try_open_completions_eventcCsht|d�r|jrdS|jrE|jj�rE|jj�dS|jddd�}|rddSdS)z�Happens when the user wants to complete his word, and if necessary,
        open a completion list after that (if there is more than one
        completion)
        �mc_stateN�breakFT)�hasattrr%rZ	is_active�completer)rrZopenedrrr�autocomplete_eventNs
zAutoComplete.autocomplete_eventcGs_|jjd�|_|jdk	r:|jj|j�n|jj|j|j|�|_dS)N�insert)r�indexrr�after_cancel�afterr�_delayed_open_completions)r�argsrrrr ^s
z$AutoComplete._open_completions_latercGs9d|_|jjd�|jkr(dS|j|�dS)Nr*)rrr+rr)rr/rrrr.fs	z&AutoComplete._delayed_open_completionscCs�|jdk	r.|jj|j�d|_nt|jd�}|jjdd�}t|�}}|j�r|s�|tkr|j	�t}x,|r�||ddt
kr�|d8}q�W|||�}	|}x(|r||ddkr|d8}q�W|||�}
n|j�r|s6|tkr|j	�t}xB|r�||dt
ks}t||d�dkr�|d8}qIW|||�}	|r
||ddkr
|jdt|�|d�|j�}
|
s|r|
jd	�dkrdSqd
}
ndS|r/|
r/|	r/dS|j|
|�}|dsOdS|j�|_|jj|dt|	�|||�S)
aXFind the completions and create the AutoCompleteWindow.
        Return True if successful (no syntax error or so found).
        if complete is True, then if there's nothing to complete and no
        start of completion, won't open completions and return False.
        If mode is given, will open a completion list only in this mode.
        Nr*zinsert linestartrz'"�rz
insert-%dc�(�r���)rrr,rrr�lenZis_in_stringr#rr"Z
is_in_coder!�ID_CHARS�ordZ	set_indexZget_expression�find�fetch_completionsrrZshow_window)rZ	evalfuncsr(ZuserWantsWin�modeZhpZcurline�i�jZ
comp_startZ	comp_whatZ
comp_listsrrrrlsN
!
7	
	zAutoComplete.open_completionsc	Cs�y|jjjjj}Wnd}YnX|rL|jdd||fi�S|tkrK|dkr�tjj	�}|j
tjj�td|�}|j
�d|kr�ttd|��}qHdd�|D�}q�yZ|j|�}t|�}|j
�d|krt|j�}nd	d�|D�}Wq�ggfSYq�Xn�|tkr�|dkrld
}nyBtjj|�}tj|�}|j
�dd�|D�}Wq�tk
r�ggfSYq�Xn|s�|}n||fSdS)aOReturn a pair of lists of completions for something. The first list
        is a sublist of the second. Both are sorted.

        If there is a Python subprocess, get the comp. list there.  Otherwise,
        either fetch_completions() is running in the subprocess itself or it
        was called in an IDLE EditorWindow before any script had been run.

        The subprocess environment is that of the most recently run script.  If
        two unrelated modules are being edited some calltips in the current
        module may be inoperative if the module was not the last to run.
        N�execZget_the_completion_listr2zdir()�__all__cSs,g|]"}|dd�dkr|�qS)Nrrr)�.0�srrr�
<listcomp>�s	z2AutoComplete.fetch_completions.<locals>.<listcomp>cSs,g|]"}|dd�dkr|�qS)Nrrr)r>r?rrrr@�s	rcSs,g|]"}|dd�dkr|�qS)Nrrr)r>r?rrrr@�s	)rZflistZpyshellZinterp�rpccltZ
remotecallr!�__main__�__dict__�copy�update�__builtins__�eval�sort�sorted�
get_entity�dirr=r#�os�path�
expanduser�listdir�OSError)	rZwhatr9rA�	namespaceZbiglZsmalllZentityZexpandedpathrrrr8�sL

	

	zAutoComplete.fetch_completionscCs,tjj�}|jtj�t||�S)zALookup name in a namespace spanning sys.modules and __main.dict__)�sys�modulesrDrErBrCrG)r�namerQrrrrJ�szAutoComplete.get_entity)r	r
)�__name__�
__module__�__qualname__ZmenudefsrZ	GetOptionrrrrrr$r)r r.rr8rJrrrrrs

;9rrB)�mainz#idlelib.idle_test.test_autocomplete�	verbosity�)�__doc__rLrR�stringZidlelib.configHandlerrZ
ascii_lettersZdigitsr5�ranger!r#ZidlelibrZidlelib.HyperParserrrB�sepr"�altseprrUZunittestrXrrrr�<module>s 		�

?>