ž ©ÿf,c@sódZddlZddlZddlZddlZddlZddlZddlmZddl m Z Gdd„dƒZ dd„Z d Z d ZdZejd ƒZdZdd„ZedkrïddlmZedddƒndS(uCallTips.py - An IDLE Extension to Jog Your Memory 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. iN(u CallTipWindow(u HyperParsercBs˜|EeZdZddgfgZddd„Zdd„Zdd „Zdd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dS(uCallTipsueditu Show call tipu<>cCsF|dkrd|_n*||_|j|_d|_|j|_dS(N(uNoneueditwinutextuactive_calltipu_make_tk_calltip_windowu_calltip_window(uselfueditwin((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyu__init__s      uCallTips.__init__cCs d|_dS(N(uNoneu_calltip_window(uself((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyuclose#suCallTips.closecCstj|jƒS(N(u CallTipWindowuCallTiputext(uself((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyu_make_tk_calltip_window&su CallTips._make_tk_calltip_windowcCs&|jr"|jjƒd|_ndS(N(uactive_calltipuhidetipuNone(uselfuevent((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyu_remove_calltip_window*s  uCallTips._remove_calltip_windowcCs|jdƒdS(u9The user selected the menu entry or hotkey, open the tip.NT(u open_calltipuTrue(uselfuevent((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyuforce_open_calltip_event/su!CallTips.force_open_calltip_eventcCs|jdƒdS(uªHappens 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. NF(u open_calltipuFalse(uselfuevent((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyutry_open_calltip_event3suCallTips.try_open_calltip_eventcCs,|jr(|jjƒr(|jdƒndS(NF(uactive_calltipu is_activeu open_calltipuFalse(uselfuevent((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyurefresh_calltip_event:suCallTips.refresh_calltip_eventcCsÆ|jƒt|jdƒ}|jdƒ}|s5dS|j|dƒ|jƒ}|s\dS| r||jdƒdkr|dS|j|ƒ}|s•dS|jƒ|_ |j j ||d|dƒdS(Nuinsertu(iiiÿÿÿÿ( u_remove_calltip_windowu HyperParserueditwinuget_surrounding_bracketsu set_indexuget_expressionufindu fetch_tipu_calltip_windowuactive_calltipushowtip(uselfu evalfuncsuhpu sur_parenu expressionuargspec((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyu open_calltip>s   uCallTips.open_calltipc Csgy|jjjjj}Wntk r3d}YnX|rS|jdd|fiƒStt |ƒƒSdS(uDReturn 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. uexecuget_the_calltipN( ueditwinuflistupyshelluinterpurpccltuAttributeErroruNoneu remotecallu get_argspecu get_entity(uselfu expressionurpcclt((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyu fetch_tipQs    uCallTips.fetch_tipN(u Show call tipu<>(u__name__u __module__u __qualname__umenudefsuNoneu__init__ucloseu_make_tk_calltip_windowu_remove_calltip_windowuforce_open_calltip_eventutry_open_calltip_eventurefresh_calltip_eventu open_calltipu fetch_tip(u __locals__((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyuCallTipss      uCallTipsc CsV|rRtjjƒ}|jtjƒyt||ƒSWqRtk rNdSYqRXndS(uwReturn the object corresponding to expression evaluated in a namespace spanning sys.modules and __main.dict__. N( usysumodulesucopyuupdateu__main__u__dict__uevalu BaseExceptionuNone(u expressionu namespace((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyu get_entityis u get_entityiUiu iu(?<=\()\w*\,?\s*uSee source or doccCsîd}y |j}Wntk r+|SYnXt|tƒrG|j}n!t|tjƒrb|}n|}t|tjtjfƒrÝtj tj |ƒŒ}t|ttjfƒsÅt|tjƒrÝt j d|ƒ}qÝnt |ƒtkrtj|tdtƒn|r|gng}t|tjƒr:|j}nt|ddƒ}|rÛxt|jdtƒdt…D]V}|jƒ}|s‹Pnt |ƒtkr¸|dtd…d}n|j|ƒqoWdj|ƒ}n|sêt}n|S(u¡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. uusubsequent_indentu__doc__u Niu...(u__call__u BaseExceptionu isinstanceutypeu__init__utypesu MethodTypeu FunctionTypeuinspectu formatargspecugetfullargspecu _first_paramusubulenu _MAX_COLSutextwrapuwrapu_INDENTu__doc__ugetattrusplitu _MAX_LINESustripuappendujoinu_default_callable_argspec(uobuargspecuob_callufobulinesudoculine((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyu get_argspecs>      ? #  u get_argspecu__main__(umainuidlelib.idle_test.test_calltipsu verbosityiu (u__doc__u__main__uinspectureusysutextwraputypesuidlelibu CallTipWindowuidlelib.HyperParseru HyperParseruCallTipsu get_entityu _MAX_COLSu _MAX_LINESu_INDENTucompileu _first_paramu_default_callable_argspecu get_argspecu__name__uunittestumain(((u5/opt/alt/python33/lib64/python3.3/idlelib/CallTips.pyus&      W  .