This commit is contained in:
Luke Rogers 2014-02-11 17:19:17 +13:00
parent d524d8fa6b
commit ddf39e4b42

View file

@ -46,14 +46,14 @@ class PluginLoader(object):
def load_all(self): def load_all(self):
"""loads plugins from all files in the plugins folder""" """runs load_file() on all python files in the plugins folder"""
files = set(glob.glob(os.path.join(self.path, '*.py'))) files = set(glob.glob(os.path.join(self.path, '*.py')))
for f in files: for f in files:
self.load_file(f, loaded_all=True) self.load_file(f, rebuild=True)
self.rebuild() self.rebuild()
def load_file(self, path, loaded_all=False): def load_file(self, path, rebuild=False):
"""loads (or reloads) all valid plugins from a specified file""" """loads (or reloads) all valid plugins from a specified file"""
filename = os.path.basename(path) filename = os.path.basename(path)
title = os.path.splitext(filename)[0] title = os.path.splitext(filename)[0]
@ -94,11 +94,10 @@ class PluginLoader(object):
for type, data in obj._hook: for type, data in obj._hook:
# add plugin to the plugin list # add plugin to the plugin list
self.bot.plugins[type] += [data] self.bot.plugins[type] += [data]
#if not loaded_all:
self.bot.logger.info("Loaded plugin: {} ({})".format(format_plug(data), type)) self.bot.logger.info("Loaded plugin: {} ({})".format(format_plug(data), type))
# do a rebuild, unless the bot is loading all plugins (rebuild happens after load_all) # do a rebuild, unless the bot is loading all plugins (rebuild happens after load_all)
if not loaded_all: if not rebuild:
self.rebuild() self.rebuild()