Skip to content

Commit

Permalink
findinfiles: Translate exclude pattern before validation
Browse files Browse the repository at this point in the history
Move the code that translates a exclude pattern outside the block
that that validates the pattern.

This way the code is easier to follow, with the translation and
validation steps clearly separated from each other.
  • Loading branch information
ehabkost committed Sep 2, 2018
1 parent 0d6686e commit bda2fff
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions spyder/widgets/findinfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,15 @@ def get_options(self, all=False):
file_search = self.path_selection_combo.is_file_search()
path = self.path_selection_combo.get_current_searchpath()

# Finding text occurrences
if not exclude_re:
items = [fnmatch.translate(item.strip())
for item in exclude.split(",")]
exclude = '|'.join(items)

# Validate regular expressions:

try:
if not exclude_re:
items = [fnmatch.translate(item.strip())
for item in exclude.split(",")]
exclude = '|'.join(items)
else:
exclude = re.compile(exclude)
exclude = re.compile(exclude)
except Exception:
exclude_edit = self.exclude_pattern.lineEdit()
exclude_edit.setStyleSheet(self.REGEX_INVALID)
Expand Down

0 comments on commit bda2fff

Please sign in to comment.