MCPcopy Index your code
hub / github.com/python/cpython / default_command

Method default_command

Lib/idlelib/grep.py:129–150  ·  view source on GitHub ↗

Grep for search pattern in file path. The default command is bound to . If entry values are populated, set OutputWindow as stdout and perform search. The search dialog is closed automatically when the search begins.

(self, event=None)

Source from the content-addressed store, hash-verified

127 self.make_button("Search Files", self.default_command, isdef=True)
128
129 def default_command(self, event=None):
130 """Grep for search pattern in file path. The default command is bound
131 to <Return>.
132
133 If entry values are populated, set OutputWindow as stdout
134 and perform search. The search dialog is closed automatically
135 when the search begins.
136 """
137 prog = self.engine.getprog()
138 if not prog:
139 return
140 path = self.globvar.get()
141 if not path:
142 self.top.bell()
143 return
144 from idlelib.outwin import OutputWindow # leave here!
145 save = sys.stdout
146 try:
147 sys.stdout = OutputWindow(self.flist)
148 self.grep_it(prog, path)
149 finally:
150 sys.stdout = save
151
152 def grep_it(self, prog, path):
153 """Search for prog within the lines of the files in path.

Callers

nothing calls this directly

Calls 5

grep_itMethod · 0.95
OutputWindowClass · 0.90
getprogMethod · 0.80
getMethod · 0.45
bellMethod · 0.45

Tested by

no test coverage detected