Ë ºç½îA͈ãóΗdZddlZddlZddlZddlmZmZddlmZddl m Z ddl m Z dd„Z d„Zd „ZGd „d e «Zd „Zed k(r ddlmZeddd¬«ddlmZee«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«}tj|«}t|d«st |||«|_|j }|jdd«}|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/lib/python3.12/idlelib/grep.pyÚgreprse€ð �:‰:‹<€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 €ä ˆ#…Jrc#󌇇K—tj|t¬«D]\Š}}ˆˆfd„|D«Ed{–—†|rŒyy7Œ ­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. )Úonerrorc3óŠ•K—|]:}tj|‰«r"tjj‰|«–—Œ<y­w©N)ÚfnmatchÚosÚpathÚjoin)Ú.0ÚnameÚdirpathÚpatterns €€rÚ zfindfiles..9s6øèø€ð7Ù )˜Ü—‘ t¨WÔ5ô—G‘G—L‘L ¨$×/Ù )ùsƒAAN)r"Úwalkr)Úfolderr(Ú recursiveÚ_Ú filenamesr's ` @rÚ findfilesr/0sJùèø€ô"$§¡¨¼×!Dш��Iô7Ù )ó7÷ 7ð 7òÙ ñ "Eð 7ús„2A¶A·A¾AcóV‡—eZdZdZdZdZdZˆfd„Zd d„Zd„Z d„Z d „Z d d „Z d „Z ˆxZS) r z$Dialog for searching multiple files.zFind in Files DialogÚGreprcót•—t‰|�||«||_t|«|_t |«|_y)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__rrÚglobvarrÚrecvar)ÚselfrrrÚ __class__s €rr4zGrepDialog.__init__Gs2ø€ô ‰Ñ˜˜vÔ&؈Œ Ü  “ˆŒ Ü  Ó&ˆ� rcód—tj|||«|r|jxsd}nd}tjj |«\}}tjj |«\}}|sd}|jjtjj|d|z««y)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) rrÚfilenamer"r#ÚsplitÚsplitextr5Úsetr$) r7rrrr#ÚdirÚbaseÚheadÚtails rrzGrepDialog.openZs‡€ô ×јd D¨,Ô7Ù Ø—;‘;Ò$ "‰DàˆDÜ—G‘G—M‘M $Ó'‰ ˆˆTÜ—W‘W×%Ñ% dÓ+‰ ˆˆdÙØˆDØ � ‰ ×ÑœŸ™Ÿ™ c¨3°©:Ó6Õ7rcóv—tj|«|jd|j«d|_y)z9Create base entry widgets and add widget for search path.z In files:rN)rÚcreate_entriesÚ make_entryr5Úglobent©r7s rrEzGrepDialog.create_entriesps+€ä×'Ñ'¨Ô-Ø—‘ {°D·L±LÓAÀ!ÑDˆ� rcó|—t|j«d|jd¬«}|jdd¬«y)z0Add check button to recurse down subdirectories.rzRecurse down subdirectories)ÚvariablerÚtopÚboth)ÚsideÚfillN)rÚ make_framer6Úpack)r7Úbtns rÚcreate_other_buttonszGrepDialog.create_other_buttonsus6€äØ—‘Ó! !Ñ$¨t¯{©{Ø2ô4ˆð �‰�e &ˆÕ)rcój—tj|«|jd|jd¬«y)z. If entry values are populated, set OutputWindow as stdout and perform search. The search dialog is closed automatically when the search begins. Nr)Ú OutputWindow) rÚgetprogr5r rKÚbellÚidlelib.outwinrYÚsysÚstdoutrÚgrep_it)r7ÚeventÚprogr#rYÚsaves rrWzGrepDialog.default_command�s€ð�{‰{×"Ñ"Ó$ˆÙØ Ø�|‰|×ÑÓ!ˆÙØ �H‰H�M‰MŒOØ Ý/Ü�z‰zˆð Ù% d§j¡jÓ1ŒCŒJØ �L‰L˜˜tÔ $àŒC�Jø˜ŒC�Jús Á,-B%Â% B2c óì—tjj|«\}}|stj}t t |||j j«««}|j«|jj«}td|›d|›d�«d} |D]z} t|d¬«5} t| d«D]Q\} } | dd d k(r| d d} |j| «sŒ%tj j#|›d | ›d | ›d �«|dz }ŒS d d d «Œ|t|r d |›d �«y d«y #1swYŒ$xYw#t$$r} t| «Yd } ~ Œ»d } ~ wwxYw#t&$rYy wxYw)a¦Search for prog within the lines of the files in path. For the each file in the path directory, open the file and search each line for the matching pattern. If the pattern is found, write the file and line information to stdout (which is an OutputWindow). Args: prog: The compiled, cooked search pattern. path: String containing the search path. z Searching z in z ...rÚreplace)ÚerrorsééÿÿÿÿNÚ z: z Hits found: z' (Hint: right-click to open locations.)zNo hits.)r"r#r=ÚcurdirÚsortedr/r6r ÚcloserÚgetpatrrÚ enumerateÚsearchr]r^ÚwriteÚOSErrorÚAttributeError) r7rar#r+ÚfilepatÚfilelistÚpatÚhitsÚfnÚfÚlinenoÚliners rr_zGrepDialog.grep_it˜sd€ôŸ'™'Ÿ-™-¨Ó-‰ˆ�ÙÜ—Y‘YˆFÜœ) F¨G°T·[±[·_±_Ó5FÓGÓHˆØ � ‰ Œ Ø�k‰k× Ñ Ó"ˆÜ � ˜3˜'  d V¨4Ð0Ô1؈ð Û�ð ܘb¨Õ3°qÜ,5°a¸®O™L˜F DØ# B C˜y¨DÒ0Ø'+¨C¨R y Ø#Ÿ{™{¨4Õ0Ü #§ ¡ × 0Ñ 0°B°4°r¸&¸ÀÀDÀ6ÈÐ1LÔ MØ $¨¡ ¡ñ -<÷4øðô Ùð!  Ð&NÐOõ +Ø)õ +÷4Ð3ûôòܘ#—J‘Jûðûôò ñ ð ús`Â"E'Â( EÂ51D:Ã'/D:ÄEÄE'Ä3E'Ä:E Ä?EÅ E$Å EÅE'ÅE$Å$E'Å' E3Å2E3r )Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚtitleÚiconÚneedwrapbuttonr4rrErRrUrWr_Ú __classcell__)r8s@rr r @s:ø„Ù*à "€EØ €DØ€Nô'ó&8ò,Eò *òKó ö.%rr có⇠‡ ‡—ddlm}m}mŠ ddlm}m}ddlm}||«}|jd«tt|j«jd«dd«\}}|jd|›d|dz›�«||«Š ||«} | j«|| d ¬ «Š‰j«‰jd d «ˆ ˆ ˆfd „} || d| ¬«} | j«y)Nr)ÚToplevelÚTextÚSEL)ÚFrameÚButton)ÚPyShellFileListzTest GrepDialogÚ+rfé¯é)Úheightú1.0z import grepcól•—‰j‰dd«t‰‰¬«‰j‰dd«y)Nr�z1.end)r)Útag_addrÚ tag_remove)r…rrs€€€rÚshow_grep_dialogz&_grep_dialog..show_grep_dialogÑs-ø€Ø � ‰ �S˜% Ô)Ü ˆT˜ÕØ �‰˜˜U GÕ,rzShow GrepDialog)rÚcommand)Útkinterrƒr„r…Ú tkinter.ttkr†r‡Úidlelib.pyshellrˆr~ÚmapÚintÚgeometryr=rPÚinsert)Úparentrƒr„r†r‡rˆrKÚxÚyÚframer‘Úbuttonr…rrs @@@rÚ _grep_dialogrŸÀsËú€ß+Ñ+ß)Ý/á �6Ó €C؇I�IÐÔ Ü Œs�F—O‘OÓ%×+Ñ+¨CÓ0°°Ð4Ó 5�D€A€q؇L�L�1�Q�C�q˜˜S™˜ Ð"Ô#á ˜CÓ €EÙ �#‹J€EØ ‡J�J„LÙ �˜aÔ €D؇I�I„K؇K�K��}Ô%ö-ñ �EÐ 1Ð;KÔ L€FØ ‡K�K…MrÚ__main__)Úmainzidlelib.idle_test.test_grepéF)Ú verbosityÚexit)Úrun)NN)r}r!r"r]r“rrr”rÚidlelib.searchbaserÚidlelibrrrr/r rŸrzÚunittestr¡Úidlelib.idle_test.htestr¥©rrÚr«soðñó Û Û ç)Ý#å/Ý ó (ò.ò ô }Ð!ô}ò@ð4 ˆzÒÝÙÐ &°!¸%Õ@å+Ùˆ Õð r