From 2c4c77acfe43e42ae4cf9447b244cb8289d1bbef Mon Sep 17 00:00:00 2001 From: ByteCommander Date: Thu, 25 Jun 2015 13:18:45 +0200 Subject: [PATCH] Shortened code Replace for-loop with list comprehension. Replace if-elif with if ... or ..., as in both cases "return True" is following. --- oratioignoreparser.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/oratioignoreparser.py b/oratioignoreparser.py index 9234572..9c78900 100644 --- a/oratioignoreparser.py +++ b/oratioignoreparser.py @@ -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