Rewrite to use a set comprehension

- using strip() isn't needed as split(sep=None) will take care of multiple whitespaces
- from 10 lines to 4, and likely a tad faster
This commit is contained in:
Laurent Monin
2021-11-09 17:45:26 +01:00
parent 37982bed94
commit cd188dcebf

View File

@@ -561,16 +561,10 @@ class File(QtCore.QObject, Item):
self._apply_additional_files_moves(moves)
def _compile_move_additional_files_pattern(self, config):
patterns = config.setting["move_additional_files_pattern"].lower()
pattern_regexes = set()
for pattern in patterns.split():
pattern = pattern.strip()
if not pattern:
continue
pattern_regex = re.compile(fnmatch.translate(pattern), re.IGNORECASE)
match_hidden = pattern.startswith('.')
pattern_regexes.add((pattern_regex, match_hidden))
return pattern_regexes
return {
(re.compile(fnmatch.translate(pattern), re.IGNORECASE), pattern.startswith('.'))
for pattern in set(config.setting["move_additional_files_pattern"].lower().split())
}
def _get_additional_files_moves(self, old_path, new_path, patterns):
moves = set()