Skip to content

Commit

Permalink
Shortened code
Browse files Browse the repository at this point in the history
Replace for-loop with list comprehension.
Replace if-elif with if ... or ..., as in both cases "return True" is following.
  • Loading branch information
ByteCommander committed Jun 25, 2015
1 parent a161727 commit 2c4c77a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions oratioignoreparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ def __init__(self):

def load(self, oratio_ignore_path):
with open(oratio_ignore_path, "r") as f:
for line in f:
self.ignored_paths.append(line.strip())
self.ignored_paths.extend([line.strip() for line in f])

def should_be_ignored(self, filepath):
for ig in self.ignored_paths:
compiled_regex = re.compile('^' + re.escape(ig).replace('\\*', '.*') + '$')
if compiled_regex.search(filepath):
return True
elif compiled_regex.search(filepath.split('/')[-1]):
if compiled_regex.search(filepath) or compiled_regex.search(filepath.split('/')[-1]):
return True
return False

Expand Down

0 comments on commit 2c4c77a

Please sign in to comment.