fFc@sdZdZdZdefdYZedjoXddklZlZedZ ei d e edd k l Z e i nd S( s This module documents a class that implements an indexer for automatic word completion. @author: Lateef Alabi-Oki @organization: The Scribes Project @copyright: Copyright © 2007 Lateef Alabi-Oki @license: GNU GPLv2 or Later @contact: mystilleef@gmail.com sorg.sourceforge.ScribesIndexers/org/sourceforge/ScribesIndexertCompletionIndexercBszeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( s This class indexes words for automatic word completion. An instance of this class runs in a separate process. The text editor communicates with this instance via D-Bus. c Cs|iddkl}||}ddkl}|d|i|ddkl}|i|iddddd d dd k l }|d dd k l }l }l}|d|i||id|dS(s Initialize object. @param self: Reference to the CompletionIndexer instance. @type self: A CompletionIndexer object. i(t DBusService(tsetcheckintervali(t session_bustNameOwnerChangedsorg.freedesktop.DBuss/org/freedesktop/DBustarg0snet.sourceforge.Scribes(tnicei(t timeout_addtidle_addt PRIORITY_LOWi' tpriorityN(t"_CompletionIndexer__start_up_checkRtsysRt#_CompletionIndexer__init_attributest SCRIBES.infoRtadd_signal_receivert"_CompletionIndexer__name_change_cbtosRtgobjectRRR t#_CompletionIndexer__check_instancest&_CompletionIndexer__precompile_methods( tselfRtdbusRRRRRR ((s!plugins/WordCompletion/Indexer.pyt__init__*s$      c Csddkl}l}|d||_ddkl}l}l}y|hdd|_Wn"|hd|d||_nX||_ d S( s Initialize data attributes. @param self: Reference to the CompletionIndexer instance. @type self: A CompletionIndexer object. i(tUNICODEtcompiles[^-\w](t DictionarytStringtInt32t signaturetsstkey_typet value_typeN( treRRt_CompletionIndexer__patternRRRRt_CompletionIndexer__empty_dictt_CompletionIndexer__dbus(RRRRRRR((s!plugins/WordCompletion/Indexer.pyt__init_attributesEs cCs'ddkl}||i||dS(s$ Index text. @param self: Reference to the CompletionIndexer instance. @type self: A CompletionIndexer object. @param text: Text to be indexed for word completion. @type text: A String object. @return: A dictionary of words for automatic completion. @rtype: A Dict object. i(RN(RRt _CompletionIndexer__process_text(RttexttidR((s!plugins/WordCompletion/Indexer.pytprocessVs cCslddkl}||o|ii||iSn|i|}|i|}|ii||tS(Ni(tnot_(toperatorR*R$tfinished_indexingR#t,_CompletionIndexer__generate_completion_listt2_CompletionIndexer__generate_completion_dictionarytFalse(RR'R(R*t completionst dictionary((s!plugins/WordCompletion/Indexer.pyt__process_textgs 'cCs]ddkl}||odSnddkl}||i|}t|i|}|S(sO Generate list of words for automatic completion. @param self: Reference to the CompletionIndexer instance. @type self: A CompletionIndexer object. @param text: Text to be indexed for word completion. @type text: A String object. @param return: A list of words for automatic completion. @type return: A List object. i(R*(tsplitN(R+R*tNoneR!R3R"tfiltert_CompletionIndexer__filter(RR'R*R3tcompletion_listR0((s!plugins/WordCompletion/Indexer.pyt__generate_completion_listos cCsddkl}||o |iSnh}ddkl}xB|D]:}||i|o||cd7tlenR/t startswithtTrue(RR;R=R>((s!plugins/WordCompletion/Indexer.pyt__filters 4cCsUy;ddkl}||i||i||iWntj onXtS(Ni(tbind(tpsycoRDR-R.R6t ImportErrorR/(RRD((s!plugins/WordCompletion/Indexer.pyt__precompile_methodss  cGsddkl}|ddS(s Quit when the Scribes process dies. @param self: Reference to the CompletionIndexer instance. @type self: A CompletionIndexer object. i(t_exitiN(RRH(RtargsRH((s!plugins/WordCompletion/Indexer.pyt__name_change_cbs cCsnddkl}|i}ddkl}l}|||todSnddkl}|ddS(Ni(t dbus_iface(R9R*(RHi( RRKt ListNamesR+R9R*tindexer_dbus_serviceRRH(RRKtservicesR9R*RH((s!plugins/WordCompletion/Indexer.pyt__start_up_checks  cCsddkl}|tS(Ni(t start_psyco(t SCRIBES.utilsRPR/(RRP((s!plugins/WordCompletion/Indexer.pyt __start_psycoscCskddkl}|i}ddkl}||itdotSnddkl }|dtS(s Periodically check for other instances. @param self: Reference to the CompletionIndexer instance. @type self: A CompletionIndexer object. i(RK(teqi(RHi( RRKRLR+RStcountRMRBRRH(RRKRNRSRH((s!plugins/WordCompletion/Indexer.pyt__check_instancess ! (t__name__t __module__t__doc__RR R)R&R-R.R6RRR t_CompletionIndexer__start_psycoR(((s!plugins/WordCompletion/Indexer.pyR#s        t__main__i(targvtpathii(tMainLoopN(RXRMtindexer_dbus_pathtobjectRRVR R[R\t python_pathtinsertRR]trun(((s!plugins/WordCompletion/Indexer.pyss