%PDF- %PDF-
Direktori : /usr/local/lib/python3.8/idlelib/__pycache__/ |
Current File : //usr/local/lib/python3.8/idlelib/__pycache__/grep.cpython-38.pyc |
U qa7 @ s d Z ddlZddlZddlZddlmZmZ ddlmZ ddl m Z ddlmZ dddZ d d Zdd ZG d d de Zdd ZedkrddlmZ 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 | }t|}t|ds*t||||_|j}| dd}|| || dS )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)Z_rootr gethasattr GrepDialogr open)textioflistrootengineZdialogsearchphrase r (/usr/local/lib/python3.8/idlelib/grep.pygrep s r c C s t | dS )zHandle os.walk error.N)print)msgr r r walk_error+ s r c # s@ t j| tdD ],\ }} fdd|D E dH |s q<qdS )zGenerate 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 s( | ] }t |rtj |V qd S )N)fnmatchospathjoin).0namedirpathpatternr r <genexpr>9 s zfindfiles.<locals>.<genexpr>N)r walkr )folderr! recursive_ filenamesr r r findfiles0 s r( c s` e Zd ZdZdZdZdZ fddZddd Zd d Z dd Z dd ZdddZdd Z ZS )r z$Dialog for searching multiple files.zFind in Files DialogZGrepr c s, t || || _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: flist: filelist.Filelist instance for OutputWindow parent. globvar: String value of Entry widget for path to search. globent: Entry widget for globvar. Created in create_entries(). recvar: Boolean value of Checkbutton widget for traversing through subdirectories. N)super__init__r r globvarr recvar)selfr r r __class__r r r* G s zGrepDialog.__init__Nc C sh t | || |r|jpd}nd}tj|\}}tj|\}}|sJd}| jtj |d| dS )a_ Make dialog visible on top of others and ready to use. Extend the SearchDialogBase open() to set the initial value for globvar. Args: text: Multicall object containing the text information. searchphrase: String phrase to search. io: iomenu.IOBinding instance containing file path. z.py*N) r r filenamer r splitsplitextr+ setr ) r- r r r r dirbaseheadtailr r r r Z s zGrepDialog.openc C s"