Your IP : 3.137.221.252


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/autocomplete.cpython-36.pyc

3

� fl$�@s�dZddlZddlZddlZedd�\ZZddlmZddl	m
Z
ddlmZddl
Z
ejejdZejZejr|eej7ZGd	d
�d
�Zej�edkr�ddlmZed
dd�dS)z�Complete either attribute names or file names.

Either on demand or after a user-selected delay after a key character,
pop up a list of candidates.
�N��)�autocomplete_w)�idleConf)�HyperParser�_c@sveZdZddd�Zedd��Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zddd�Z
dd�Zdd�ZdS)�AutoCompleteNcCs,||_|dk	r(|j|_d|_d|_d|_dS)N)�editwin�text�autocompletewindow�_delayed_completion_id�_delayed_completion_index)�selfr	�r�9/opt/alt/python36/lib64/python3.6/idlelib/autocomplete.py�__init__szAutoComplete.__init__cCstjdddddd�|_dS)N�
extensionsr�	popupwait�intr)�type�default)rZ	GetOptionr)�clsrrr�reload)szAutoComplete.reloadcCstj|j�S)N)rZAutoCompleteWindowr
)rrrr�_make_autocomplete_window.sz&AutoComplete._make_autocomplete_windowcCs|jr|jj�d|_dS)N)rZhide_window)r�eventrrr�_remove_autocomplete_window1s
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.
        TF�break)�open_completions)rrrrr�force_open_completions_event6sz)AutoComplete.force_open_completions_eventcCsB|jjd�}|dkr&|jdddt�n|tkr>|jdddt�dS)z�Happens when it would be nice to open a completion list, but not
        really necessary, for example after a 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_event=s

z'AutoComplete.try_open_completions_eventcCsdt|d�r|js$|jjdd�j�r(dS|jrF|jj�rF|jj�dS|jddd�}|r\dSdSdS)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_statezinsert linestart�insertNrFT)	�hasattrr&r
r �striprZ	is_active�completer)rrZopenedrrr�autocomplete_eventJs
zAutoComplete.autocomplete_eventcGsD|jjd�|_|jdk	r&|jj|j�|jj|j|jf|��|_dS)Nr')r
�indexr
r�after_cancel�afterr�_delayed_open_completions)r�argsrrrr![s

z$AutoComplete._open_completions_latercGs&d|_|jjd�|jkr"|j|�dS)Nr')rr
r,r
r)rr0rrrr/csz&AutoComplete._delayed_open_completionscCs�|jdk	r|jj|j�d|_t|jd�}|jjdd�}t|�}}|j�r�|sZ|tkr�|j	�t}x$|r�||ddt
kr�|d8}qhW|||�}	|}x |r�||ddkr�|d8}q�W|||�}
n�|j�o�|s�|tk�r�|j	�t}x:|�r*||dt
k�s t||d�dk�r*|d8}q�W|||�}	|�r�||ddk�r�|jdt|�|d�|j�}
|
�s�|�r�|
jd	�dk�r�dSnd
}
ndS|�r�|
�r�|	�r�dS|j|
|�}|d�s�dS|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���)rr
r-rr	r �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_listsrrrrhsN
0

zAutoComplete.open_completionsc	Csjy|jjjjj}Wnd}YnX|r<|jdd||fi�S|tkr�|dkr�tjj	�}|j
tjj�td|�}|j
�d|kr�ttd|��}q�dd�|D�}nPy@|j|�}t|�}|j
�d|kr�t|j�}nd	d�|D�}WnggfSnd|tk�rT|dk�rd
}y0tjj|�}tj|�}|j
�dd�|D�}Wntk
�rRggfSX|�s^|}||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_listr3zdir()�__all__cSs g|]}|dd�dkr|�qS)Nrrr)�.0�srrr�
<listcomp>�sz2AutoComplete.fetch_completions.<locals>.<listcomp>cSs g|]}|dd�dkr|�qS)Nrrr)r?r@rrrrA�srcSs g|]}|dd�dkr|�qS)Nrrr)r?r@rrrrA�s)r	ZflistZpyshellZinterp�rpccltZ
remotecallr"�__main__�__dict__�copy�update�__builtins__�eval�sort�sorted�
get_entity�dirr>r$�os�path�
expanduser�listdir�OSError)	rZwhatr:rB�	namespaceZbiglZsmalllZentityZexpandedpathrrrr9�sL








zAutoComplete.fetch_completionscCs tjj�}|jtj�t||�S)zALookup name in a namespace spanning sys.modules and __main.dict__)�sys�modulesrErFrCrDrH)r�namerRrrrrK�s
zAutoComplete.get_entity)N)N)N)�__name__�
__module__�__qualname__r�classmethodrrrrr%r+r!r/rr9rKrrrrrs



;9rrC)�mainz#idlelib.idle_test.test_autocomplete)�	verbosity�)�__doc__rM�stringrS�ranger"r$ZidlelibrZidlelib.configrZidlelib.hyperparserrrCZ
ascii_lettersZdigitsr6�sepr#�altseprrrVZunittestrZrrrr�<module>s$
H

?>