From 730c2ba40352ef4248461a10f560d10b08b9db35 Mon Sep 17 00:00:00 2001 From: jensdepuydt Date: Wed, 18 Feb 2015 12:07:35 +0100 Subject: [PATCH] minor change to not search in non-existing paths --- lib/ansible/utils/plugins.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/ansible/utils/plugins.py b/lib/ansible/utils/plugins.py index fbee4bde684..8d356fa0a71 100644 --- a/lib/ansible/utils/plugins.py +++ b/lib/ansible/utils/plugins.py @@ -175,18 +175,19 @@ class PluginLoader(object): found = None for path in [p for p in self._get_paths() if p not in self._searched_paths]: - for potential_file in os.listdir(path): - for suffix in suffixes: - if potential_file.endswith(suffix): - full_path = os.path.join(path, potential_file) - 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 - + if os.path.isdir(path): + for potential_file in os.listdir(path): + for suffix in suffixes: + if potential_file.endswith(suffix): + full_path = os.path.join(path, potential_file) + 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: