Add support for subdirectories in the plugins directory.

svn: r11631
This commit is contained in:
Brian Matherly 2009-01-16 16:21:54 +00:00
parent b77c14b74a
commit a6fa59cc35

View File

@ -123,15 +123,6 @@ class PluginManager(gen.utils.Callback):
if not os.path.isdir(direct): if not os.path.isdir(direct):
return False # return value is True for error return False # return value is True for error
# if the path has not already been loaded, save it in the loaddir_list
# list for use on reloading
if direct not in self.__loaddir_list:
self.__loaddir_list.append(direct)
# add the directory to the python search path
sys.path.append(direct)
pymod = re.compile(r"^(.*)\.py$") pymod = re.compile(r"^(.*)\.py$")
# loop through each file in the directory, looking for files that # loop through each file in the directory, looking for files that
@ -139,7 +130,17 @@ class PluginManager(gen.utils.Callback):
# add it to the success_list list. If it fails, add it to the _failure # add it to the success_list list. If it fails, add it to the _failure
# list # list
for filename in os.listdir(direct): for (dirpath, dirnames, filenames) in os.walk(direct):
# add the directory to the python search path
sys.path.append(dirpath)
# if the path has not already been loaded, save it in the
# loaddir_list list for use on reloading.
if dirpath not in self.__loaddir_list:
self.__loaddir_list.append(dirpath)
for filename in filenames:
name = os.path.split(filename) name = os.path.split(filename)
match = pymod.match(name[1]) match = pymod.match(name[1])
if not match: if not match:
@ -151,6 +152,7 @@ class PluginManager(gen.utils.Callback):
self.__success_list.append((filename, _module)) self.__success_list.append((filename, _module))
except: except:
self.__failmsg_list.append((filename, sys.exc_info())) self.__failmsg_list.append((filename, sys.exc_info()))
return len(self.__failmsg_list) != 0 # return True if there are errors return len(self.__failmsg_list) != 0 # return True if there are errors
def reload_plugins(self): def reload_plugins(self):