%PDF- %PDF-
Direktori : /usr/local/lib/python3.8/idlelib/__pycache__/ |
Current File : //usr/local/lib/python3.8/idlelib/__pycache__/calltip.cpython-38.pyc |
U qac @ s d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m Z G dd dZdd Zd Z d ZdZedZd ZdZdd ZedkrddlmZ eddd dS )zPop up a reminder of how to call a function. Call Tips are floating windows which display function, class, and method parameter and docstring information when you type an opening parenthesis, and which disappear when you type a closing parenthesis. N) calltip_w)HyperParserc @ sX e Zd ZdddZdd Zdd Zddd Zd d Zdd Zdd Z dd Z dd ZdS )CalltipNc C s0 |d krd | _ n|| _ |j| _d | _| j| _d S N)editwintextactive_calltip_make_tk_calltip_window_calltip_window)selfr r +/usr/local/lib/python3.8/idlelib/calltip.py__init__ s zCalltip.__init__c C s d | _ d S r )r r r r r close s z Calltip.closec C s t | jS r )r Z CalltipWindowr r r r r r s zCalltip._make_tk_calltip_windowc C s | j r| j d | _ d S r )r Zhidetipr eventr r r remove_calltip_window$ s zCalltip.remove_calltip_windowc C s | d dS )z9The user selected the menu entry or hotkey, open the tip.Tbreakopen_calltipr r r r force_open_calltip_event) s z Calltip.force_open_calltip_eventc C s | d dS )zHappens when it would be nice to open a calltip, but not really necessary, for example after an opening bracket, so function calls won't be made. FNr r r r r try_open_calltip_event. s zCalltip.try_open_calltip_eventc C s | j r| j jr| d d S )NF)r Z tipwindowr r r r r refresh_calltip_event5 s zCalltip.refresh_calltip_eventc C s t | jd}|d}|s&| dS | jr`tt|d d\}}||f| jj| jj fkr`dS | |d z| }W n tk r d}Y nX |sdS | |s| ddkrdS | |}|sdS | | _| j||d |d dS )zMaybe close an existing calltip and maybe open a new calltip. Called from (force_open|try_open|refresh)_calltip_event functions. insert(Nr . )r r Zget_surrounding_bracketsr r mapintsplitZ parenlineZparencolZ set_indexZget_expression ValueErrorfind fetch_tipr Zshowtip)r Z evalfuncsZhpZ sur_parenZopener_lineZ opener_col expressionargspecr r r r 9 s6 zCalltip.open_calltipc C sR z| j jjjj}W n tk r* d}Y nX |rB|dd|fi S tt|S dS )aD Return the argument list and docstring of a function or class. If there is a Python subprocess, get the calltip there. Otherwise, either this fetch_tip() is running in the subprocess or it was called in an IDLE running without the subprocess. 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. To find methods, fetch_tip must be fed a fully qualified name. NexecZget_the_calltip) r flistZpyshellZinterprpccltAttributeErrorZ remotecallget_argspec get_entity)r r% r) r r r r$ l s zCalltip.fetch_tip)N)N)__name__ __module____qualname__r r r r r r r r r$ r r r r r s 3r c C s8 | r4t jtj}zt| |W S tk r2 Y dS X dS )zwReturn the object corresponding to expression evaluated in a namespace spanning sys.modules and __main.dict__. N)sysmodules__main____dict__eval BaseException)r% namespacer r r r, s r, U z z(?<=\()\w*\,?\s*zSee source or doczinvalid method signaturec C sL z | j }W n tk r Y dS X t|tjr2|n| }ztt|}W nD tk r } z&t|}| t rxt W Y S d}W 5 d}~X Y nX t|tr|dkrt}t |tkrtj|ttdn|r|gng }t| }|r8|dtdt D ]D}| }|s q8t |tkr,|dtd d }|| qd|}|pJtS )a Return a string describing the signature of a callable object, or ''. For Python-coded functions and methods, the first line is introspected. Delete 'self' parameter for classes (.__init__) and bound methods. The next lines are the first lines of the doc string up to the first empty line or _MAX_LINES. For builtins, this typically includes the arguments in addition to the return value. Nz())subsequent_indent z...)__call__r5 isinstancetypes MethodTypestrinspectZ signature Exception startswith_invalid_methodtype_default_callable_argspeclen _MAX_COLStextwrapwrap_INDENTZgetdocr! _MAX_LINESstripappendjoin) obZob_callZfobr&