There was a problem hiding this comment.
Thanks for the PR, some small point should be changed.
|
|
||
|
|
||
| class GrepDialog(SearchDialogBase): | ||
| "Search Dialog for Find in Files." |
There was a problem hiding this comment.
"""Search dialog for find in files."""
There was a problem hiding this comment.
The menu item is 'Find in Files', but I agree it is not obvious and awkward if one does not notice. "Find in Files" is already in file docstring. How about "Dialog for searching multiple files."?
| needwrapbutton = 0 | ||
|
|
||
| def __init__(self, root, engine, flist): | ||
| """Create Search Dialog for searching for a phrase in the file system. |
There was a problem hiding this comment.
"""Create search dialog for ...
| self.recvar = BooleanVar(root) | ||
|
|
||
| def open(self, text, searchphrase, io=None): | ||
| "Make dialog visible on top of others and ready to use." |
There was a problem hiding this comment.
"""Make dialog visible .... """
There was a problem hiding this comment.
No. Single double quote is allowed and preferred by me. Common in stdlib.
| self.globvar.set(os.path.join(dir, "*" + tail)) | ||
|
|
||
| def create_entries(self): | ||
| "Create base entry widgets and add widget for search path." |
There was a problem hiding this comment.
"""Create base entry .... path."""
| self.globent = self.make_entry("In files:", self.globvar)[0] | ||
|
|
||
| def create_other_buttons(self): | ||
| "Add check button to recurse down subdirectories." |
There was a problem hiding this comment.
"""Add check button ....subdirectories."""
| btn.pack(side="top", fill="both") | ||
|
|
||
| def create_command_buttons(self): | ||
| "Create base command buttons and add button for search." |
There was a problem hiding this comment.
"""Create base command .... for search."""
| prog = self.engine.getprog() | ||
| if not prog: | ||
| return | ||
| return None |
There was a problem hiding this comment.
return will return None. So you don't need to explicit return None
There was a problem hiding this comment.
"Either all return statements in a function should return an expression, or none of them should." So if any must (return an expression), all must, but if all return None, then none must, so None can be omitted but must be omitted everywhere.
| if self.top: | ||
| self.top.grab_release() | ||
| self.top.withdraw() | ||
| "Close the dialog." |
|
Terry had changed my """ quotes on a previous PR to just " when the docstring was only one line. I was following his convention with these changes. |
|
|
||
|
|
||
| class GrepDialog(SearchDialogBase): | ||
| "Search Dialog for Find in Files." |
There was a problem hiding this comment.
The menu item is 'Find in Files', but I agree it is not obvious and awkward if one does not notice. "Find in Files" is already in file docstring. How about "Dialog for searching multiple files."?
| @@ -1,3 +1,8 @@ | |||
| """Grep dialog for Find in File functionality. | |||
| Args: | ||
| text: Text widget that contains the selected text for | ||
| default search phrase. | ||
| io: IOBinding with default path to search. |
There was a problem hiding this comment.
'iomenu.IOBinding instance'
| needwrapbutton = 0 | ||
|
|
||
| def __init__(self, root, engine, flist): | ||
| """Create Search Dialog for searching for a phrase in the file system. |
| self.recvar = BooleanVar(root) | ||
|
|
||
| def open(self, text, searchphrase, io=None): | ||
| "Make dialog visible on top of others and ready to use." |
There was a problem hiding this comment.
No. Single double quote is allowed and preferred by me. Common in stdlib.
| "(Hint: right-click to open locations.)" | ||
| % hits) if hits else "No hits.") | ||
| "(Hint: right-click to open locations.)" | ||
| % hits) if hits else "No hits.") |
There was a problem hiding this comment.
I believe this was technically correct as it was, but it looks better with the extra space. But I don't really like it either way (and I wrote it in this form). In 3.6+, we can do
print(f"Hits found: {hits}\n"
f"(Hint: right-click to open locations.)"
if hits else "No hits.")
# or with 79 char lines
print(f"Hits found: {hits}\n(Hint: right-click to open locations.)"
if hits else "No hits.")
I like both of these better, so choose one.
There was a problem hiding this comment.
Changed. I also changed the other string formatting lines to use f strings.
| self.top.grab_release() | ||
| self.top.withdraw() | ||
| "Close the dialog." | ||
| SearchDialogBase.close(self, event) |
There was a problem hiding this comment.
Good catch. Maybe these were once different. Now, just delete GrepDialog.close and inherit SearchDialogBase.close.
| self.globvar.set(os.path.join(dir, "*" + tail)) | ||
|
|
||
| def create_entries(self): | ||
| "Create base entry widgets and add widget for search path." |
| self.globent = self.make_entry("In files:", self.globvar)[0] | ||
|
|
||
| def create_other_buttons(self): | ||
| "Add check button to recurse down subdirectories." |
| self.grep_it(prog, path) | ||
| finally: | ||
| sys.stdout = save | ||
| return None |
There was a problem hiding this comment.
" If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None " So if no return statement return an expression, no explicit return is needed at the end. In other words, this function was within the rules and should be left as it was.
|
@mlouielu @terryjreedy Thanks for the reviews. I added an additional note to default_command to mention that the search dialog is closed when the search begins. One other question -- when I run this, the dialog box always opens way on the bottom of my screen. Has anyone requested a change to this before? Or would it be worth mentioning on idle-dev? |
|
@csabella I think your question should also post it on b.p.o. Since here is to discuss about code review. I didn't get this on macOS, the dialog show off at the left top side of the screen. |
Patch by Cheryl Sabella (cherry picked from commit 65474b9)
No description provided.