3 fV @ s d Z ddlZddlZddlZddlmZmZ ddlmZ ddl m Z ddlmZ dddZ G d d d e Zdd Zed krddlmZ edddd ddlmZ ee dS )zGrep dialog for Find in Files functionality. Inherits from SearchDialogBase for GUI and uses searchengine to prepare search pattern. N) StringVar BooleanVar)Checkbutton)SearchDialogBase)searchenginec C sN | j }tj|}t|ds*t||||_|j}| jdd}|j| || dS )a& Create or find singleton GrepDialog instance. 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)Z_rootr gethasattr GrepDialogr open)textioflistrootengineZdialogsearchphrase r 1/opt/alt/python36/lib64/python3.6/idlelib/grep.pygrep s r c @ s` e Zd ZdZdZdZdZdd Zddd Zd d Z dd Z dd ZdddZdd Z dd ZdS )r z$Dialog for searching multiple files.zFind in Files DialogZGrepr c C s, t j| || || _t|| _t|| _dS )a Create search dialog for searching for a phrase in the file system. Uses SearchDialogBase as the basis for the GUI and a searchengine instance to prepare the search. Attributes: globvar: Value of Text Entry widget for path to search. recvar: Boolean value of Checkbutton widget for traversing through subdirectories. N)r __init__r r globvarr recvar)selfr r r r r r r . s zGrepDialog.__init__Nc C sh t j| || |r|jpd}nd}tjj|\}}tjj|\}}|sJd}| jjtjj |d| dS )z6Make dialog visible on top of others and ready to use. z.py*N) r r filenameospathsplitsplitextr setjoin) r r r r r dirbaseheadtailr r r r > s zGrepDialog.openc C s" t j| | jd| jd | _dS )z9Create base entry widgets and add widget for search path.z In files:r N)r create_entriesZ make_entryr Zglobent)r r r r r&