Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.10/idlelib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.10/idlelib/__pycache__/replace.cpython-310.pyc
o

�9j'�@s�dZddlZddlmZmZddlmZddlmZddd�Z	Gdd	�d	e�Z
d
d�ZedkrHdd
l
mZedddd�ddlmZee�dSdS)z�Replace dialog for IDLE. Inherits SearchDialogBase for GUI.
Uses idlelib.searchengine.SearchEngine for search capability.
Defines various replace related functions like replace, replace all,
and replace+find.
�N)�	StringVar�TclError)�SearchDialogBase)�searchenginecCs@|��}t�|�}t|d�st||�|_|j}|j||d�dS)z�Create or reuse a singleton ReplaceDialog instance.

    The singleton dialog saves user entries and preferences
    across instances.

    Args:
        text: Text widget containing the text to be searched.
    �_replacedialog)�insert_tagsN)�_rootr�get�hasattr�
ReplaceDialogr�open)�textr�root�engine�dialog�r�&/usr/lib/python3.10/idlelib/replace.py�replaces	

rcs�eZdZdZdZdZ�fdd�Zd dd�Zd	d
�Zdd�Z	d d
d�Z
d dd�Zd dd�Zdd�Z
d dd�Zd!dd�Zdd�Zdd�Zd dd�Z�ZS)"rz3Dialog for finding and replacing a pattern in text.zReplace Dialog�Replacecs"t��||�t|�|_d|_dS)a�Create search dialog for finding and replacing text.

        Uses SearchDialogBase as the basis for the GUI and a
        searchengine instance to prepare the search.

        Attributes:
            replvar: StringVar containing 'Replace with:' value.
            replent: Entry widget for replvar.  Created in
                create_entries().
            ok: Boolean used in searchengine.search_text to indicate
                whether the search includes the selection.
        N)�super�__init__r�replvarr)�selfrr��	__class__rrr%s

zReplaceDialog.__init__NcCs�t�||�z|�d�}Wntyd}Ynwz|�d�}Wnty+d}Ynw|p2|�d�}|p6|}|�||�d|_||_dS)z�Make dialog visible on top of others and ready to use.

        Also, highlight the currently selected text and set the
        search to include the current selection (self.ok).

        Args:
            text: Text widget being searched.
        �	sel.firstN�sel.last�insertT)rr�indexr�show_hit�okr)rr
r�first�lastrrrr6s 	��
zReplaceDialog.opencCs"t�|�|�d|j�d|_dS)z8Create base and additional label and text entry widgets.z
Replace with:rN)r�create_entries�
make_entryr�replent�rrrrr#Ns
zReplaceDialog.create_entriescCsJt�|�|�d|j�|�d|j�|jd|jdd�|�d|j�dS)z�Create base and additional command buttons.

        The additional buttons are for Find, Replace,
        Replace+Find, and Replace All.
        �FindrzReplace+FindT)�isdefzReplace AllN)r�create_command_buttons�make_button�find_it�
replace_it�default_command�replace_allr&rrrr)Ss

z$ReplaceDialog.create_command_buttonscCs|�d�dS)zHandle the Find button.FN)�do_find�r�eventrrrr+_szReplaceDialog.find_itcCs|�|j�r|��dSdS)z]Handle the Replace button.

        If the find is successful, then perform replace.
        N�r/r �
do_replacer0rrrr,cs�zReplaceDialog.replace_itcCs*|�|j�r|��r|�d�dSdSdS)z�Handle the Replace+Find button as the default command.

        First performs a replace and then, if the replace was
        successful, a find next.
        FNr2r0rrrr-ks
�zReplaceDialog.default_commandcCsL|j��r"z|�|�}W|Stjy!|j�|d�d}Y|Sw|}|S)z.Expand replacement text if regular expression.zInvalid Replace ExpressionN)r�isre�expand�re�error�report_error)r�m�repl�newrrr�_replace_expandvs
��zReplaceDialog._replace_expandcCs�|j��}|s	dS|j��}|j}|j�||�}|s |��dS|�ddd�|�ddd�|d}|d��}|j�	�rAd}d}d}d}	}
|�
�|jj||||d	|d
�}r�|\}}|�d|d|d�}|��}
|�
||�}|durxnM|��\}}d||f}	d||f}
||
kr�|�d
|
�n|�d
|	�|	|
kr�|�|	|
�|r�|�|	||j�|t|�}d	}|jj||||d	|d
�}sY|��|	r�|
r�|�|	|
�|��dS)a�Handle the Replace All button.

        Search text for occurrences of the Find value and replace
        each of them.  The 'wrap around' value controls the start
        point for searching.  If wrap isn't set, then the searching
        starts at the first occurrence after the current selection;
        if wrap is set, the replacement starts at the first line.
        The replacement is always done top-to-bottom in the text.
        N�sel�1.0�end�hitr�TF)�wrapr �%d.0�%d.%dr)r�getprogrr	r
�search_text�bell�
tag_remove�start�iswrap�undo_block_start�search_forward�groupr<�span�mark_set�deleterr�len�undo_block_stopr�close)rr1�progr:r
�res�line�colr r!r"r9�chars�origr;�i�jrrrr.�s^




��
�zReplaceDialog.replace_allFc
Csv|j��sdS|j}|j�|d|�}|s|��dS|\}}|��\}}d||f}d||f}	|�||	�d|_dS)z|Search for and highlight next occurrence of pattern in text.

        No text replacement is done with this option.
        FNrDT)rrEr
rFrGrNrr )
rr r
rUrVr9rZr[r!r"rrrr/�s
zReplaceDialog.do_findcCs|j��}|s	dS|j}z|�d�}}|�d�}Wnty%d}Ynw|s1|�d�}}}t�|�\}}|�d|d|d�}|�||�}	|sNdS|�	|	|j
���}
|
dur]dS|�d|�|��|	�
�rq|�||�|
r{|�||
|j�|��|�||�d��d|_dS)	z6Replace search pattern in text with replacement value.FrrNrrCrAT)rrEr
rrr�get_line_colr	�matchr<rrOrKrMrPrrrRrr )rrTr
r!�posr"rVrWrXr9r;rrrr3�s<
�zReplaceDialog.do_replacecCsv|j}|�d|�|�ddd�|�d||�|�ddd�||kr)|�d|�n|�d||�|�d�|��dS)a�Highlight text between first and last indices.

        Text is highlighted via the 'hit' tag and the marked
        section is brought into view.

        The colors from the 'hit' tag aren't currently shown
        when the text is displayed.  This is due to the 'sel'
        tag being added first, so the colors in the 'sel'
        config are seen instead of the colors for 'hit'.
        rr=r>r?r@N)r
rOrH�tag_add�see�update_idletasks)rr!r"r
rrrr�s
zReplaceDialog.show_hitcCs&t�||�|j�ddd�d|_dS)z%Close the dialog and remove hit tags.r@r>r?N)rrSr
rHrr0rrrrSs
zReplaceDialog.close�N)F)�__name__�
__module__�__qualname__�__doc__�title�iconrrr#r)r+r,r-r<r.r/r3rrS�
__classcell__rrrrrs"





8 rc
s�ddlm}m}m�m�ddlm}m}||�}|�d�t	t
|���d�dd��\}}|�d||df�d	d
�}dd�}	||�}
|
�
�||
d
d��|�_|	�_��
���dd�������fdd�}||
d|d�}|�
�dS)Nr)�Toplevel�Text�END�SEL)�Frame�ButtonzTest ReplaceDialog�+rAz+%d+%d�cS�dSrbrrrrrrK�z)_replace_dialog.<locals>.undo_block_startcSrrrbrrrrrrRrsz(_replace_dialog.<locals>.undo_block_stop�gray)�inactiveselectbackgroundrz"This is a sample sTring
Plus MORE.cs(���d��t�����d��dS)Nr>)r_rrHr�rlrmr
rr�show_replace&sz%_replace_dialog.<locals>.show_replacer)r
�command)�tkinterrjrkrlrm�tkinter.ttkrnrorg�map�int�geometry�split�packrKrRr�	focus_set)
�parentrjrkrnro�top�x�yrKrR�framerw�buttonrrvr�_replace_dialog
s&
 r��__main__)�mainzidlelib.idle_test.test_replace�F)�	verbosity�exit)�runrb)rfr6ryrr�idlelib.searchbaser�idlelibrrrr�rc�unittestr��idlelib.idle_test.htestr�rrrr�<module>s
o!�

Youez - 2016 - github.com/yon3zu
LinuXploit