Refactor loop to only calculate the full_path once
This commit is contained in:
parent
68c99a12b3
commit
0f4b72cdfa
1 changed files with 5 additions and 6 deletions
|
@ -176,19 +176,18 @@ class PluginLoader(object):
|
|||
found = None
|
||||
for path in [p for p in self._get_paths() if p not in self._searched_paths]:
|
||||
if os.path.isdir(path):
|
||||
for potential_file in (f for f in os.listdir(path)
|
||||
if os.path.isfile(os.path.join(path, f))):
|
||||
full_paths = (os.path.join(path, f) for f in os.listdir(path))
|
||||
for full_path in (f for f in full_paths if os.path.isfile(f)):
|
||||
for suffix in suffixes:
|
||||
if potential_file.endswith(suffix):
|
||||
full_path = os.path.join(path, potential_file)
|
||||
if full_path.endswith(suffix):
|
||||
full_name = os.path.basename(full_path)
|
||||
break
|
||||
else: # Yes, this is a for-else: http://bit.ly/1ElPkyg
|
||||
continue
|
||||
|
||||
|
||||
if full_name not in self._plugin_path_cache:
|
||||
self._plugin_path_cache[full_name] = full_path
|
||||
|
||||
|
||||
self._searched_paths.add(path)
|
||||
for full_name in potential_names:
|
||||
if full_name in self._plugin_path_cache:
|
||||
|
|
Loading…
Reference in a new issue