1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #9685 from bcoca/plugin_load_precedence

changed plugin load priority to be path based, not suffix based.
This commit is contained in:
Brian Coca 2014-12-02 14:45:39 -05:00
commit 84bcc6a123

View file

@ -167,17 +167,20 @@ class PluginLoader(object):
else: else:
suffixes = ['.py', ''] suffixes = ['.py', '']
# loop over paths and then loop over suffixes to find plugin
for i in self._get_paths():
for suffix in suffixes: for suffix in suffixes:
full_name = '%s%s' % (name, suffix) full_name = '%s%s' % (name, suffix)
if full_name in self._plugin_path_cache: if full_name in self._plugin_path_cache:
return self._plugin_path_cache[full_name] return self._plugin_path_cache[full_name]
for i in self._get_paths():
path = os.path.join(i, full_name) path = os.path.join(i, full_name)
if os.path.isfile(path): if os.path.isfile(path):
self._plugin_path_cache[full_name] = path self._plugin_path_cache[full_name] = path
return path return path
# if nothing is found, try finding alias/deprecated
if not name.startswith('_'): if not name.startswith('_'):
return self.find_plugin('_' + name, suffixes, transport) return self.find_plugin('_' + name, suffixes, transport)