łň /ŕ`Fc@s,dZdZdZdefd„ƒYZdS(s( This module documents a class that updates the word completion dictionary when text is entered into the text editor's buffer. @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/ScribesIndexertCompletionUpdatercBs•eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„ZRS(se This class creates an object updates the word completion dictionary when the buffer is modified. c Cs |i||ƒddkl}ddkl}l}||iƒ||id|ƒ|ii d|i ƒ|_ |ii i d|iƒ|_|ii d|iƒ|_|ii d|i ƒ|_|ii|id d d d d tƒ|ii|id ddtƒdS(s> Initialize object. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. @param manager: Reference to the CompletionManager instance. @type manager: A CompletionManager object. @param editor: Reference to the text editor. @type editor: An Editor object. i˙˙˙˙(tstart_new_thread(tidle_addt PRIORITY_LOWtprioritysloaded-documenttchangedtdestroysrenamed-documenttNameOwnerChangedsorg.freedesktop.DBuss/org/freedesktop/DBustarg0t signal_nametfinished_indexingtdbus_interfaceN(t#_CompletionUpdater__init_attributestthreadRtgobjectRRt!_CompletionUpdater__start_indexert&_CompletionUpdater__precompile_methodst_CompletionUpdater__editortconnectt&_CompletionUpdater__loaded_document_cbt_CompletionUpdater__signal_id_1t textbuffert connect_aftert_CompletionUpdater__changed_cbt_CompletionUpdater__signal_id_2t_CompletionUpdater__managert_CompletionUpdater__destroy_cbt_CompletionUpdater__signal_id_3t_CompletionUpdater__signal_id_4t session_bustadd_signal_receivert"_CompletionUpdater__name_change_cbtindexer_dbus_servicet(_CompletionUpdater__finished_indexing_cb(tselftmanagerteditorRRR((s!plugins/WordCompletion/Updater.pyt__init__)s$  cCsˇddkl}l}|tƒdƒd|_||idƒ|_ddkl}|dd|_||_ ||_ d |_ d |_ t|_d |_|_d |_|_d S( sF Initialize data attributes. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. @param manager: Reference to the CompletionManager instance. @type manager: A CompletionManager object. @param editor: Reference to the text editor. @type editor: An Editor object. i˙˙˙˙(tjointsplitt__file__is Indexer.py(tprefixs/bins/pythonN(tos.pathR&R'tglobalst_CompletionUpdater__indexer_cwdt&_CompletionUpdater__indexer_executabletsysR)t%_CompletionUpdater__python_executableRRtNonet_CompletionUpdater__timert_CompletionUpdater__indexertFalset_CompletionUpdater__is_indexingRRRR(R"R#R$R&R'R)((s!plugins/WordCompletion/Updater.pyt__init_attributesIs      cCs¨ddkl}l}||iiƒotSn||idƒo%ddkl }||i ƒtSn|i ƒddkl }l }|d|id|ƒ|_tS(s‘ Generate word completion dictionary. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. i˙˙˙˙(tis_ttruth(R(t timeout_addRiôRN(toperatorR6R7Rt is_readonlyR3R2R0RRRt _CompletionUpdater__remove_timerR8Rt'_CompletionUpdater__generate_dictionaryR1(R"R6R7RR8R((s!plugins/WordCompletion/Updater.pyt__indexis  c CsĎ|ioYddkl}l}yt|iƒWntj onX||id|ƒ|_niddkl }||i ƒodSnt |_|i i |i ƒ|iidtd|id|iƒtS( sű Generate word completion dictionary. Send text to the indexer, an external process, to generate a list of words for automatic completion. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. i˙˙˙˙(RRR(tnot_NR t reply_handlert error_handler(R4RRRt source_removet_CompletionUpdater__index_timert Exceptiont_CompletionUpdater__indexR9R>R2tTruetprocesst_CompletionUpdater__get_textRtidR t$_CompletionUpdater__reply_handler_cbt$_CompletionUpdater__error_handler_cbR3(R"RRR>((s!plugins/WordCompletion/Updater.pyt__generate_dictionary{s    c Csyddkl}ddkl}l}l}|iƒ}ddkl}d |_ ||t ƒon|i t t ƒ|_ ddkl}l}yt|iƒWntj onX||id|ƒ|_n3ddkl} | |i|i|gd|iƒWn|j onXtS( sŠ Start the word completion indexer and get a reference to it. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. i˙˙˙˙(t DBusException(t dbus_ifaceRt python_path(tcontains(RRR(t spawn_asynctworking_directoryN(tdbusRLt SCRIBES.infoRMRRNt ListNamesR9ROR0R2R t get_objecttindexer_dbus_pathRRRRARBRCRDRPR/R-R,R3( R"RLRMRRNtservicesRORRRP((s!plugins/WordCompletion/Updater.pyt__start_indexer–s&  &cCs.d„}t||iiƒƒ}di|ƒS(s˝ Get text from all editors. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. @return: text to index. @rtype: A String object. cSs |iƒS((tget_text(R$((s!plugins/WordCompletion/Updater.pytźst (tmapRtget_editor_instancesR&(R"RYtall_text((s!plugins/WordCompletion/Updater.pyt __get_text˛s cCs/y!ddkl}||iƒWnnXdS(sŚ Remove timer assocated with a time out function callback. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. i˙˙˙˙(RAN(RRAR1(R"RA((s!plugins/WordCompletion/Updater.pyt__remove_timerŔs cCsYddkl}l}yt|iƒWntj onX||id|ƒ|_tS(s Handles callback when the "changed" signal is emitted. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. @param textbuffer: Reference to the text editor's buffer. @type textbuffer: A ScribesTextBuffer object. i˙˙˙˙(RRR(RRRRARBRCRDR3(R"RRR((s!plugins/WordCompletion/Updater.pyt __changed_cbÔs cCsYddkl}l}yt|iƒWntj onX||id|ƒ|_dS(sý Handles callback when the "loaded-document" signal is emitted. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. @param editor: Reference to the text editor. @type editor: An Editor object. i˙˙˙˙(RRRN(RRRRARBRCRD(R"R$turiRR((s!plugins/WordCompletion/Updater.pyt__loaded_document_cbćs cGs!ddkl}||iƒdS(s× Callback when the indexing process dies. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. @param *args: Useless arguments. @type *args: A List object. i˙˙˙˙(RN(RRR(R"targsR((s!plugins/WordCompletion/Updater.pyt__name_change_cbřs  cGsdS(sĺ Successful message from the indexer @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. @param dictionary: Word completion dictionary. @type dictionary: A Dict object. N((R"Rd((s!plugins/WordCompletion/Updater.pyt__reply_handler_cbs cCs!dGHdGH|GHdGHt|_dS(sö Handles callback when an error message is received from the indexer. @param self: Reference to the CompletionUpdater instance. @type self: A CompletionUpdater object. @param error: An error message. @type error: A String object. s#INDEXER ERROR: Failed to index texts8========================================================N(R3R4(R"terror((s!plugins/WordCompletion/Updater.pyt__error_handler_cbs  cCsTddkl}|||iiƒodSn|iidt|ƒƒt|_dS(Ni˙˙˙˙(tnetupdate( R9RiRRHRtemittdictR3R4(R"t editor_idt dictionaryRi((s!plugins/WordCompletion/Updater.pyt__finished_indexing_cb&s  cCs|iii|idddddtƒ|iii|idddtƒd |_|iƒy!dd k l }||i ƒWnt j onX|ii |i|iƒ|ii |i|iiƒ|ii |i|iƒ|ii |i|iƒ|ii|ƒ~d }d S( s  Handles callback when the "destroy" signal is emitted. @param self: Reference to the CompletionUpdater instance. @type self: An CompletionUpdater object. @param manager: Reference to the CompletionManager. @type manager: An CompletionManager object. Rsorg.freedesktop.DBuss/org/freedesktop/DBusRR R R i˙˙˙˙(RAN(RRtremove_signal_receiverRR R!R0R2R;RRARBRCtdisconnect_signalRRRRRRtdelete_attributes(R"R#RA((s!plugins/WordCompletion/Updater.pyt __destroy_cb-s0   cCsUy;ddkl}||iƒ||iƒ||iƒWntj onXtS(Ni˙˙˙˙(tbind(tpsycoRtRDR<Rt ImportErrorR3(R"Rt((s!plugins/WordCompletion/Updater.pyt__precompile_methodsPs  (t__name__t __module__t__doc__R%R RDR<RRGR;RRRRIRJR!RR(((s!plugins/WordCompletion/Updater.pyR#s             #N(RzR RVtobjectR(((s!plugins/WordCompletion/Updater.pyss