5 # Copyright (C) 2008 Christopher R. Gabriel <cgabriel@truelite.it>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
18 def load_plugins(pluginpath=None, nick="octofuss"):
19 """return a list of all available plugins
20 in the given directory"""
23 pluginpath = os.environ.get(nick.upper() + "_PLUGINS", "plugins")
25 # if the plugin path need to be auto-discovered
26 # starting from a specified module
27 #pluginpath = os.path.join(os.path.dirname(imp.find_module("octofussd")[1]), "extensions/")
29 pluginfiles = [fname[:-3] for fname in os.listdir(pluginpath) if fname.endswith(".py") and not fname.startswith(".") and not fname.endswith("~")]
31 for fname in pluginfiles:
34 sys.path.append(os.path.abspath(pluginpath))
35 res = imp.load_source(fname, os.path.join(pluginpath, fname) + ".py")