%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/idlelib/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/idlelib/__pycache__/searchengine.cpython-38.pyc

U

q©ßaÂã@s~dZddlZddlmZmZmZddlmZdd„ZGdd„dƒZd	d
„Z	dd„Z
d
d„Zedkrzddl
mZeddddS)z'Define SearchEngine for search dialogs.éN)Ú	StringVarÚ
BooleanVarÚTclError)Ú
messageboxcCst|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
ú0/usr/local/lib/python3.8/idlelib/searchengine.pyÚgets

rc@seZdZdZdd„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)	r	rÚpatvarrÚrevarÚcasevarÚwordvarÚwrapvarÚbackvar)Úselfr	r
r
rÚ__init__szSearchEngine.__init__cCs
|j ¡S©N)rr©rr
r
rÚgetpat%szSearchEngine.getpatcCs|j |¡dSr)rÚset©rÚpatr
r
rÚsetpat(szSearchEngine.setpatcCs
|j ¡Sr)rrrr
r
rÚisre+szSearchEngine.isrecCs
|j ¡Sr)rrrr
r
rÚiscase.szSearchEngine.iscasecCs
|j ¡Sr)rrrr
r
rÚisword1szSearchEngine.iswordcCs
|j ¡Sr)rrrr
r
rÚiswrap4szSearchEngine.iswrapcCs
|j ¡Sr)rrrr
r
rÚisback7szSearchEngine.isbackcCs | ¡rt |¡}| |¡dS)z!Set pattern after escaping if re.N)rÚreÚescaperrr
r
rÚsetcookedpat<s
zSearchEngine.setcookedpatcCs.| ¡}| ¡st |¡}| ¡r*d|}|S)Nz\b%s\b)rrr"r#rrr
r
rÚgetcookedpatCs
zSearchEngine.getcookedpatc
CsŒ| ¡}|s| |d¡dS| ¡}d}| ¡s:|tjB}zt ||¡}Wn<tjk
r†}z| ||j|j	¡WY¢dSd}~XYnX|S)z&Return compiled cooked search pattern.zEmpty regular expressionNr)
rÚreport_errorr%rr"Ú
IGNORECASEÚcompileÚerrorÚmsgÚpos)rrÚflagsÚprogÚer
r
rÚgetprogKs
zSearchEngine.getprogNcCsNdt|ƒ}|r |dt|ƒ}|dk	r8|dt|ƒ}tjd||jddS)NzError: z

Pattern: z	
Offset: zRegular expression error)Zmaster)ÚstrrZ	showerrorr	)rrr*Úcolr
r
rr&\sÿzSearchEngine.report_errorrcCs”|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Úliner1Úresr
r
rÚsearch_textfs$
zSearchEngine.search_textcCs°d}|}| d|d|d¡}	|	r¬| |	dd…|¡}
|
rT|sL|
 ¡|krT||
fS|d}|rj||krjq¬d}d}| d|d|d¡}	|	s |r d}d}d}| dd¡}	q dS)Nrú%d.0ééÿÿÿÿz1.0z2.0)rÚsearchÚend)rr6r-r<r1r8r7ÚwrappedÚ	startlineÚcharsÚmr
r
rr5Žs(zSearchEngine.search_forwardcCsÈd}|}| d|d|d¡}	t||	dd…|ƒ}
|
rP|sH|
 ¡|krP||
fS|d}|rf||krfqÄd}|dkrž|sxqÄd}d}| d¡}tt| d¡ƒ\}}| d|d|d¡}	t|	ƒd}q dS)Nrr?r@rAzend-1cÚ.)rÚsearch_reverser;ÚindexÚmapÚintÚsplitÚlen)rr6r-r<r1r8r7rDrErFrGr+r
r
rr4¤s*
zSearchEngine.search_backward)N)Nr)r)r)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rrrrrrr r!r$r%r/r&r>r5r4r
r
r
rrs 


(
rcCsj| |¡}|sdSd}| ¡\}}||krf||krf|}||krF|d}| ||¡}|sXqf| ¡\}}q"|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@)rBÚspan)r-rFr1rGÚfoundÚiÚjr
r
rrI½s
rIcCsTz| 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)rJr)r6r9r:r
r
rr2Ôs

r2cCstt| d¡ƒ\}}||fS)z8Return (line, col) tuple of ints from 'line.col' string.rH)rKrLrM)rJr<r1r
r
rr3âsr3Ú__main__)Úmainz#idlelib.idle_test.test_searchengineé)Ú	verbosity)rRr"ÚtkinterrrrrrrrIr2r3rOZunittestrYr
r
r
rÚ<module>s+

Zerion Mini Shell 1.0