ó {fc@sdZddlZddlZddlZddlmZejejejdZ ejejdZ e ddƒ\Z Z ddlmZdd lmZddlZejZejrÌeej7Znd dd „ƒYZed krdd lmZedddƒndS(sÖAutoComplete.py - An IDLE extension for automatically completing names. This extension can complete either attribute names or file names. It can pop a window with all available names, for the user to select from. iÿÿÿÿN(tidleConfs._~#$:-t_ii(tAutoCompleteWindow(t HyperParsert AutoCompletecBs§eZddgfgZejddddddd ƒZdd „Zd „Zdd „Z d „Z d„Z d„Z d„Z d„Zdd„Zd„Zd„ZRS(teditsShow Completionss<>t extensionsRt popupwaitttypetinttdefaulticCsD||_|dkrdS|j|_d|_d|_d|_dS(N(teditwintNonettexttautocompletewindowt_delayed_completion_idt_delayed_completion_index(tselfR ((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyt__init__)s     cCstj|jƒS(N(RR (R((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyt_make_autocomplete_window6scCs&|jr"|jjƒd|_ndS(N(Rt hide_windowR (Rtevent((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyt_remove_autocomplete_window9s  cCs|jtttƒdS(sqHappens when the user really wants to open a completion list, even if a function call is needed. N(topen_completionstTruetFalse(RR((s,/usr/lib64/python2.7/idlelib/AutoComplete.pytforce_open_completions_event>scCs`|jjdƒ}|dkr7|jttttƒn%|tkr\|jttttƒndS(s¥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. s insert-1ct.N(R tgett_open_completions_laterRtCOMPLETE_ATTRIBUTEStSEPStCOMPLETE_FILES(RRtlastchar((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyttry_open_completions_eventDs   cCsht|dƒr|jrdS|jrE|jjƒrE|jjƒdS|jtttƒ}|rddSdS(s¥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) tmc_stateNtbreak(thasattrR#Rt is_activetcompleteRRR(RRtopened((s,/usr/lib64/python2.7/idlelib/AutoComplete.pytautocomplete_eventQs cGs_|jjdƒ|_|jdk r:|jj|jƒn|jj|j|j|Œ|_dS(Ntinsert( R tindexRRR t after_canceltafterRt_delayed_open_completions(Rtargs((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyRas cGs9d|_|jjdƒ|jkr(dS|j|ŒdS(NR*(R RR R+RR(RR/((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyR.is c Csb|jdk r.|jj|jƒd|_nt|jdƒ}|jjddƒ}t|ƒ}}|jƒr| s„|t kr|j ƒt }x(|r¾||dt kr¾|d8}q—W|||!} |}x,|r||dt t kr|d8}qÕW|||!} nã|j ƒrð| s0|tkrð|j ƒt}x(|rj||dtkrj|d8}qCW|||!} |rç||ddkrç|jdt|ƒ|dƒ|jƒ} | sà| rí| jdƒdkrídSqôd } ndS|r | r | r dS|j| |ƒ} | d s,dS|jƒ|_|jj| dt| ƒ|||ƒ S( sXFind 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. R*sinsert linestartiRs insert-%dct(iÿÿÿÿNti(RR R R,RR Rtlent is_in_stringR RtFILENAME_CHARSRt is_in_codeRtID_CHARSt set_indextget_expressiontfindtfetch_completionsRRt show_window( Rt evalfuncsR't userWantsWintmodethptcurlinetitjt comp_startt comp_whatt comp_lists((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyRosN   !      c Cs&y|jjjjj}Wn d }nX|rK|jdd||fiƒS|tkrr|dkrîtj j ƒ}|j tj j ƒt d|ƒ}|jƒd|krÂtt d|ƒƒ}qog|D]}|d dkrÉ|^qÉ}q yp|j|ƒ}t|ƒ}|jƒd|kr4t|jƒ}n)g|D]}|d dkr;|^q;}Wq ggfSXn—|tkr |dkr“d}nyXtjj|ƒ} tj| ƒ}|jƒg|D]}|d dkrÈ|^qÈ}Wq tk rggfSXn|s|}n||fSd S( sOReturn 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. texectget_the_completion_listR1sdir()t__all__iRRN(R tflisttpyshelltinterptrpccltR t remotecallRt__main__t__dict__tcopytupdatet __builtins__tevaltsorttsortedt get_entitytdirRHR tostpatht expandusertlistdirtOSError( RtwhatR>RLt namespacetbigltsmallltstentityt expandedpath((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyR:£sL       ,   -    -  cCs,tjjƒ}|jtjƒt||ƒS(sALookup name in a namespace spanning sys.modules and __main.dict__(tsystmodulesRPRQRNRORS(RtnameR^((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyRVÜs(sShow Completionss<>N(t__name__t __module__tmenudefsRt GetOptionRR RRRRR"R)RR.RR:RV(((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyRs        4 9RN(tmains#idlelib.idle_test.test_autocompletet verbosityi((t__doc__RXRdtstringtidlelib.configHandlerRt ascii_letterstdigitstcurdirR4R6trangeRR tidlelibRtidlelib.HyperParserRRNtsepRtaltsepRRgtunittestRk(((s,/usr/lib64/python2.7/idlelib/AutoComplete.pyts"      Å