|
|
|
@ -96,8 +96,6 @@ class PluginLoader(object):
|
|
|
|
self.package_path = os.path.join(os.path.dirname(m.__file__), *parts)
|
|
|
|
self.package_path = os.path.join(os.path.dirname(m.__file__), *parts)
|
|
|
|
paths.extend(self._all_directories(self.package_path))
|
|
|
|
paths.extend(self._all_directories(self.package_path))
|
|
|
|
return paths
|
|
|
|
return paths
|
|
|
|
else:
|
|
|
|
|
|
|
|
return [ self.package_path ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_paths(self):
|
|
|
|
def _get_paths(self):
|
|
|
|
''' Return a list of paths to search for plugins in '''
|
|
|
|
''' Return a list of paths to search for plugins in '''
|
|
|
|
@ -105,8 +103,7 @@ class PluginLoader(object):
|
|
|
|
if self._paths is not None:
|
|
|
|
if self._paths is not None:
|
|
|
|
return self._paths
|
|
|
|
return self._paths
|
|
|
|
|
|
|
|
|
|
|
|
ret = []
|
|
|
|
ret = self._extra_dirs[:]
|
|
|
|
ret += self._extra_dirs
|
|
|
|
|
|
|
|
for basedir in _basedirs:
|
|
|
|
for basedir in _basedirs:
|
|
|
|
fullpath = os.path.realpath(os.path.join(basedir, self.subdir))
|
|
|
|
fullpath = os.path.realpath(os.path.join(basedir, self.subdir))
|
|
|
|
if os.path.isdir(fullpath):
|
|
|
|
if os.path.isdir(fullpath):
|
|
|
|
@ -139,11 +136,9 @@ class PluginLoader(object):
|
|
|
|
|
|
|
|
|
|
|
|
# look for any plugins installed in the package subtree
|
|
|
|
# look for any plugins installed in the package subtree
|
|
|
|
ret.extend(self._get_package_paths())
|
|
|
|
ret.extend(self._get_package_paths())
|
|
|
|
package_dirs = self._get_package_paths()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# cache and return the result
|
|
|
|
self._paths = ret
|
|
|
|
self._paths = ret
|
|
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -156,7 +151,9 @@ class PluginLoader(object):
|
|
|
|
if with_subdir:
|
|
|
|
if with_subdir:
|
|
|
|
directory = os.path.join(directory, self.subdir)
|
|
|
|
directory = os.path.join(directory, self.subdir)
|
|
|
|
if directory not in self._extra_dirs:
|
|
|
|
if directory not in self._extra_dirs:
|
|
|
|
|
|
|
|
# append the directory and invalidate the path cache
|
|
|
|
self._extra_dirs.append(directory)
|
|
|
|
self._extra_dirs.append(directory)
|
|
|
|
|
|
|
|
self._paths = None
|
|
|
|
|
|
|
|
|
|
|
|
def find_plugin(self, name, suffixes=None, transport=''):
|
|
|
|
def find_plugin(self, name, suffixes=None, transport=''):
|
|
|
|
''' Find a plugin named name '''
|
|
|
|
''' Find a plugin named name '''
|
|
|
|
|