Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/thread-self/root/proc/thread-self/root/lib64/python2.7/idlelib/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/proc/thread-self/root/lib64/python2.7/idlelib/SearchEngine.pyc

�
{fc@s�dZddlZddlmZmZmZddlZd�Zddd��YZd�Z	d�Z
d	�Zed
kr�ddl
Z
e
jddd
de�ndS(s'Define SearchEngine for search dialogs.i����N(t	StringVart
BooleanVartTclErrorcCs(t|d�s!t|�|_n|jS(s�Return the singleton SearchEngine instance for the process.

    The single SearchEngine saves settings between dialog instances.
    If there is not a SearchEngine already, make one.
    t
_searchengine(thasattrtSearchEngineR(troot((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytgetsRcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
dd
�Zddd�Zdd�Zdd�ZRS(s<Handles searching a text widget for Find, Replace, and Grep.cCsy||_t|d�|_t|t�|_t|t�|_t|t�|_t|t�|_	t|t�|_
dS(s�Initialize Variables that save search state.

        The dialogs bind these to the UI elements present in the dialogs.
        tN(RRtpatvarRtFalsetrevartcasevartwordvartTruetwrapvartbackvar(tselfR((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyt__init__s	cCs
|jj�S(N(R	R(R((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytgetpat#scCs|jj|�dS(N(R	tset(Rtpat((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytsetpat&scCs
|jj�S(N(RR(R((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytisre)scCs
|jj�S(N(RR(R((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytiscase,scCs
|jj�S(N(R
R(R((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytisword/scCs
|jj�S(N(RR(R((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytiswrap2scCs
|jj�S(N(RR(R((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytisback5scCs/|j�rtj|�}n|j|�dS(s!Set pattern after escaping if re.N(RtretescapeR(RR((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytsetcookedpat:scCsG|j�}|j�s*tj|�}n|j�rCd|}n|S(Ns\b%s\b(RRRRR(RR((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytgetcookedpatAs
cCs�|j�}|s&|j|d�dS|j�}d}|j�sT|tjB}nytj||�}Wn_tjk
r�}|j	}|d}t
|�dkr�|dnd}|j|||�dSX|S(s&Return compiled cooked search pattern.sEmpty regular expressioniiii����N(Rtreport_errortNoneRRRt
IGNORECASEtcompileterrortargstlen(RRtflagstprogtwhatR%tmsgtcol((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytgetprogIs"	
"i����cCsmdt|�}|r-|dt|�}n|dkrP|dt|�}ntjd|d|j�dS(NsError: s

Pattern: is	
Offset: sRegular expression errortmaster(tstrttkMessageBoxt	showerrorR(RRR*R+((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyR ]s	icCs�|s|j�}|sdSn|jj�}t|�\}}|j�r�|r[|}n|}t|�\}}	|j||||	||�}
nE|r�|}n|}t|�\}}	|j||||	||�}
|
S(s�Return (lineno, matchobj) or None for forward/backward search.

        This function calls the right function with the right arguments.
        It directly return the result of that call.

        Text is a text widget. Prog is a precompiled pattern.
        The ok parameter is a bit complicated as it has two effects.

        If there is a selection, the search begin at either end,
        depending on the direction setting and ok, with ok meaning that
        the search starts with the selection. Otherwise, search begins
        at the insert mark.

        To aid progress, the search functions do not return an empty
        match at the starting position unless ok is True.
        N(	R,R!RRt
get_selectionRtget_line_coltsearch_backwardtsearch_forward(RttextR(toktwraptfirsttlasttstarttlineR+tres((s,/usr/lib64/python2.7/idlelib/SearchEngine.pytsearch_textgs$	!	cCs�d}|}|jd|d|d�}	x�|	r�|j|	d |�}
|
rt|sg|
j�|krt||
fSn|d}|r�||kr�Pnd}d}|jd|d|d�}	|	r-|r-d}d}d}|jdd�}	q-q-WdS(Nis%d.0ii����s1.0s2.0(RtsearchtendR!(RR5R(R;R+R7R6twrappedt	startlinetcharstm((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyR4�s(	


cCsd}|}|jd|d|d�}	x�t||	d |�}
|
rn|sa|
j�|krn||
fSn|d}|r�||kr�Pnd}|dkr�|s�Pnd}d}|jd�}tt|jd��\}}n|jd|d|d�}	t|	�d}q-WdS(Nis%d.0ii����send-1ct.(	Rtsearch_reverseR:tindextmaptinttsplitR&R!(RR5R(R;R+R7R6R@RARBRCtpos((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyR3�s,

!N(t__name__t
__module__t__doc__RRRRRRRRRRR,R R!R=R4R3(((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyRs 											
(cCs�|j|�}|sdSd}|j�\}}xi||kr�||kr�|}||krk|d}n|j||�}|s�Pn|j�\}}q4W|S(s&Search backwards and return an re match object or None.

    This is done by searching forwards until there is no match.
    Prog: compiled re object with a search method returning a match.
    Chars: line of text, without \n.
    Col: stop index for the search; the limit for match.end().
    iN(R>R!tspan(R(RBR+RCtfoundtitj((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyRE�s
cCsqy"|jd�}|jd�}Wntk
r?d}}nX|sX|jd�}n|sg|}n||fS(sFReturn tuple of 'line.col' indexes from selection or insert mark.
    s	sel.firstssel.lasttinsertN(RFRR!(R5R8R9((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyR1�s
	cCs(tt|jd��\}}||fS(s8Return (line, col) tuple of ints from 'line.col' string.RD(RGRHRI(RFR;R+((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyR2�st__main__s#idlelib.idle_test.test_searchenginet	verbosityitexit((RMRtTkinterRRRR/RRRER1R2RKtunittesttmainR
(((s,/usr/lib64/python2.7/idlelib/SearchEngine.pyt<module>s	�			

Hacked By AnonymousFox1.0, Coded By AnonymousFox