Sindbad~EG File Manager
�
%Μga � �� � d Z ddlZddlZddlZddlmZmZ ddlmZ ddl m
Z
ddlmZ dd�Z
d� Zd � Z G d
� de
� Zd� Zed
k( r ddlmZ eddd�� ddlmZ ee� yy)z�Grep dialog for Find in Files functionality.
Inherits from SearchDialogBase for GUI and uses searchengine
to prepare search pattern.
� N)� StringVar�
BooleanVar)�Checkbutton)�SearchDialogBase)�searchenginec �� � | j � }t j |� }t |d� st |||� |_ |j
}| j dd� }|j
| ||� y)a� Open the Find in Files dialog.
Module-level function to access the singleton GrepDialog
instance and open the dialog. If text is selected, it is
used as the search phrase; otherwise, the previous entry
is used.
Args:
text: Text widget that contains the selected text for
default search phrase.
io: iomenu.IOBinding instance with default path to search.
flist: filelist.FileList instance for OutputWindow parent.
�_grepdialogz sel.firstzsel.lastN)�_rootr �get�hasattr�
GrepDialogr �open)�text�io�flist�root�engine�dialog�searchphrases �)/usr/local/lib/python3.12/idlelib/grep.py�grepr se � � �:�:�<�D�
�
�
�d�
#�F��6�=�)�'��f�e�<���
�
�
�F��8�8�K��4�L�
�K�K��l�B�'� c � � t | � y)zHandle os.walk error.N)�print)�msgs r �
walk_errorr + s � � �#�Jr c # � ��K � t j | t �� D ] \ �}}��fd�|D � E d{ ��� |r� y y7 ��w)z�Generate file names in dir that match pattern.
Args:
folder: Root directory to search.
pattern: File pattern to match.
recursive: True to include subdirectories.
)�onerrorc 3 � �K � | ]: }t j |�� r"t j j �|� �� �< y �w�N)�fnmatch�os�path�join)�.0�name�dirpath�patterns ��r � <genexpr>zfindfiles.<locals>.<genexpr>9 s6 �� �� � 7� )�����t�W�5� �G�G�L�L��$�/� )�s �A AN)r"