Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/idlelib/__pycache__/searchengine.cpython-37.opt-1.pyc

B

� f0�@s~dZddlZddlmZmZmZddlmZdd�Z	Gdd�d�Z
dd	�Zd
d�Zdd
�Z
edkrzddlmZeddd�dS)z'Define SearchEngine for search dialogs.�N)�	StringVar�
BooleanVar�TclErrorcCst|d�st|�|_|jS)z�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.
    �
_searchengine)�hasattr�SearchEnginer)�root�r	�9/opt/alt/python37/lib64/python3.7/idlelib/searchengine.py�gets

rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd#dd�Zd$dd�Zd%dd �Zd&d!d"�ZdS)'rz<Handles searching a text widget for Find, Replace, and Grep.cCsR||_t|d�|_t|d�|_t|d�|_t|d�|_t|d�|_t|d�|_dS)z�Initialize Variables that save search state.

        The dialogs bind these to the UI elements present in the dialogs.
        �FTN)	rr�patvarr�revar�casevar�wordvar�wrapvar�backvar)�selfrr	r	r
�__init__szSearchEngine.__init__cCs
|j��S)N)r
r)rr	r	r
�getpat%szSearchEngine.getpatcCs|j�|�dS)N)r
�set)r�patr	r	r
�setpat(szSearchEngine.setpatcCs
|j��S)N)rr)rr	r	r
�isre+szSearchEngine.isrecCs
|j��S)N)rr)rr	r	r
�iscase.szSearchEngine.iscasecCs
|j��S)N)rr)rr	r	r
�isword1szSearchEngine.iswordcCs
|j��S)N)rr)rr	r	r
�iswrap4szSearchEngine.iswrapcCs
|j��S)N)rr)rr	r	r
�isback7szSearchEngine.isbackcCs |��rt�|�}|�|�dS)z!Set pattern after escaping if re.N)r�re�escaper)rrr	r	r
�setcookedpat<s
zSearchEngine.setcookedpatcCs.|��}|��st�|�}|��r*d|}|S)Nz\b%s\b)rrrrr)rrr	r	r
�getcookedpatCs
zSearchEngine.getcookedpatc
Cs�|��}|s|�|d�dS|��}d}|��s:|tjB}yt�||�}WnXtjk
r�}z8|j}|d}t	|�dkr�|dnd}|�|||�dSd}~XYnX|S)z&Return compiled cooked search pattern.zEmpty regular expressionNr�����)
r�report_errorr!rr�
IGNORECASE�compile�error�args�len)rr�flags�progZwhatr)�msg�colr	r	r
�getprogKs"
zSearchEngine.getprogr$cCsNdt|�}|r |dt|�}|dkr8|dt|�}tjd||jd�dS)NzError: z

Pattern: rz	
Offset: zRegular expression error)Zmaster)�str�tkMessageBoxZ	showerrorr)rrr-r.r	r	r
r%_szSearchEngine.report_errorNrcCs�|s|��}|sdS|j��}t|�\}}|��rb|r<|}n|}t|�\}}	|�||||	||�}
n.|rl|}n|}t|�\}}	|�||||	||�}
|
S)a�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/rr�
get_selectionr�get_line_col�search_backward�search_forward)r�textr,�ok�wrap�first�last�start�liner.Zresr	r	r
�search_textis$
zSearchEngine.search_textcCs�d}|}|�d|d|d�}	x�|	r�|�|	dd�|�}
|
rV|sN|
��|krV||
fS|d}|rl||krlPd}d}|�d|d|d�}	|	s"|r"d}d}d}|�dd�}	q"WdS)Nrz%d.0r#r$z1.0z2.0)r�search�end)rr6r,r<r.r8r7�wrapped�	startline�chars�mr	r	r
r5�s(zSearchEngine.search_forwardcCs�d}|}|�d|d|d�}	x�t||	dd�|�}
|
rR|sJ|
��|krR||
fS|d}|rh||krhPd}|dkr�|szPd}d}|�d�}tt|�d��\}}|�d|d|d�}	t|	�d}q"WdS)Nrz%d.0r#r$zend-1c�.)r�search_reverser;�index�map�int�splitr*)rr6r,r<r.r8r7r@rArBrC�posr	r	r
r4�s,
zSearchEngine.search_backward)r$)Nr)r)r)�__name__�
__module__�__qualname__�__doc__rrrrrrrrr r!r/r%r=r5r4r	r	r	r
rs 


(
rcCsn|�|�}|sdSd}|��\}}xF||krh||krh|}||krH|d}|�||�}|sZP|��\}}q$W|S)a&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().
    Nr#)r>�span)r,rBr.rC�found�i�jr	r	r
rE�s
rEcCsTy|�d�}|�d�}Wntk
r4d}}YnX|sD|�d�}|sL|}||fS)zFReturn tuple of 'line.col' indexes from selection or insert mark.
    z	sel.firstzsel.lastN�insert)rFr)r6r9r:r	r	r
r2�s

r2cCstt|�d��\}}||fS)z8Return (line, col) tuple of ints from 'line.col' string.rD)rGrHrI)rFr<r.r	r	r
r3�sr3�__main__)�mainz#idlelib.idle_test.test_searchenginer")�	verbosity)rNrZtkinterrrrZtkinter.messageboxZ
messageboxr1rrrEr2r3rKZunittestrUr	r	r	r
�<module>s.

Hacked By AnonymousFox1.0, Coded By AnonymousFox