ó {fc@sÌdZddlZddlZddlZddlZddlZddlmZddlm Z ddd„ƒYZ d„Z dZ d Z dZd „Zed krÈddlmZedddƒndS(sCallTips.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. iÿÿÿÿN(t CallTipWindow(t HyperParsertCallTipscBszeZdd gfgZdd„Zd„Zd„Zdd„Zd„Zd„Z d „Z d „Z d „Z d „Z RS(tedits Show call tips<>cCsG|dkrd|_dS||_|j|_d|_|j|_dS(N(tNoneteditwinttexttcalltipt_make_tk_calltip_windowt_make_calltip_window(tselfR((s(/usr/lib64/python2.7/idlelib/CallTips.pyt__init__s     cCs d|_dS(N(RR (R ((s(/usr/lib64/python2.7/idlelib/CallTips.pytclose#scCstj|jƒS(N(RtCallTipR(R ((s(/usr/lib64/python2.7/idlelib/CallTips.pyR&scCs&|jr"|jjƒd|_ndS(N(RthidetipR(R tevent((s(/usr/lib64/python2.7/idlelib/CallTips.pyt_remove_calltip_window*s  cCs|jtƒdS(siHappens when the user really wants to open a CallTip, even if a function call is needed. N(t open_calltiptTrue(R R((s(/usr/lib64/python2.7/idlelib/CallTips.pytforce_open_calltip_event/scCs|jtƒdS(sª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. N(RtFalse(R R((s(/usr/lib64/python2.7/idlelib/CallTips.pyttry_open_calltip_event5scCs,|jr(|jjƒr(|jtƒndS(siIf there is already a calltip window, check if it is still needed, and if so, reload it. N(Rt is_activeRR(R R((s(/usr/lib64/python2.7/idlelib/CallTips.pytrefresh_calltip_event<scCsÃ|jƒt|jdƒ}|jdƒ}|s5dS|j|dƒ|jƒ}| su| ry|jdƒdkrydS|j|ƒ}|s’dS|jƒ|_ |j j ||d|dƒdS(Ntinsertt(iiÿÿÿÿi( RRRtget_surrounding_bracketst set_indextget_expressiontfindt fetch_tipR Rtshowtip(R t evalfuncsthpt sur_parent expressiontarg_text((s(/usr/lib64/python2.7/idlelib/CallTips.pyRCs  #cCsoy|jjjjj}Wntk r2d}nX|rR|jdd|fiƒS|j|ƒ}t |ƒSdS(sRReturn the argument list and docstring of a function or class If there is a Python subprocess, get the calltip there. Otherwise, either fetch_tip() 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. To find methods, fetch_tip must be fed a fully qualified name. texectget_the_calltipN( RtflisttpyshelltinterptrpcclttAttributeErrorRt remotecallt get_entityt get_arg_text(R R#R*tentity((s(/usr/lib64/python2.7/idlelib/CallTips.pyRTs    cCsR|rNtjjƒ}|jtjƒyt||ƒSWqNtk rJdSXndS(sReturn the object corresponding to expression evaluated in a namespace spanning sys.modules and __main.dict__. N( tsystmodulestcopytupdatet__main__t__dict__tevalt BaseExceptionR(R R#t namespace((s(/usr/lib64/python2.7/idlelib/CallTips.pyR-ms (s Show call tips<>N(t__name__t __module__tmenudefsRR R RRRRRRRR-(((s(/usr/lib64/python2.7/idlelib/CallTips.pyRs        cCsVy|jjSWnAtk rQx1|jD]"}t|ƒ}|dk r(|Sq(WnXdS(N(R tim_funcR+t __bases__t_find_constructorR(tclass_obtbasetrc((s(/usr/lib64/python2.7/idlelib/CallTips.pyR>{s   iUit icCsTd}y |j}Wn3tk rHt|ƒtjkrA|}qI|SnXd}t|ƒtjtjfkršt|ƒ}|dkr‘d„}qd}nft|ƒtjkrÓ|j }|j dk rd}qn-t|ƒtjkrú|j }d}n|}t|ƒtj tj gkr^|j j}|j j||!}|jpIg}ttd„|ƒƒ}dgt|ƒt|ƒ|}td„||ƒ}x–ddfD]ˆ\} } } |j j| @r§| | } | |krì|j| ƒq/d} x"| d | |kr| d7} qõW|j| d | ƒq§q§Wdj|ƒ}dtjdd|ƒ}nt|ƒtkrˆtj|tdtƒn|r—|gng}t|tjƒr»|j}nt|ddƒ}|rPxh|j dt!ƒt! D]P}|j"ƒ}|sPnt|ƒtkr-|td d}n|j|ƒqêWdj|ƒ}n|S(s¡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. ticSsdS(N(R(((s(/usr/lib64/python2.7/idlelib/CallTips.pyt£RCicSsdt|ƒS(Ns=%s(trepr(tname((s(/usr/lib64/python2.7/idlelib/CallTips.pyRD·RCcSs||S(N((targtdflt((s(/usr/lib64/python2.7/idlelib/CallTips.pyRD¹RCit*targsis**tkwargss%ss, s(%s)s (?tsubsequent_indentt__doc__s is...N(iRIRJ(is**RK(#t__call__R7ttypettypest ClassTypetTypeTypeR>Rt MethodTypeR<tim_selft FunctionTypet LambdaTypet func_codet co_argcountt co_varnamest func_defaultstlisttmaptlentco_flagstappendtjointretsubt _MAX_COLSttextwraptwrapt_INDENTt isinstanceRMtgetattrtsplitt _MAX_LINEStstrip(tobtargspectob_callt arg_offsettfobtargcountt real_argstdefaultstitemstflagtpreRFtpre_nametitlinestdoctline((s(/usr/lib64/python2.7/idlelib/CallTips.pyR.‹sj             !  ?  R4(tmainsidlelib.idle_test.test_calltipst verbosityi(s (RMR4RaR0RdRPtidlelibRtidlelib.HyperParserRRR>RcRjRfR.R9tunittestR|(((s(/usr/lib64/python2.7/idlelib/CallTips.pyts      i  N