Do not store the install directory in directories.plugins

We automatically determine the directory anyway, so there's no need to clutter
the config file with it.  Instead, simply include the directory when we
perform the search for the plugin.

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-03-12 14:50:46 -04:00
parent 22da325656
commit 6986fc7abe
2 changed files with 9 additions and 15 deletions

View File

@ -37,9 +37,6 @@ import supybot.utils as utils
import supybot.registry as registry import supybot.registry as registry
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
installDir = os.path.dirname(sys.modules[__name__].__file__)
_pluginsDir = os.path.join(installDir, 'plugins')
### ###
# version: This should be pretty obvious. # version: This should be pretty obvious.
### ###
@ -737,18 +734,11 @@ registerGlobalValue(supybot.directories.data, 'tmp',
utils.file.AtomicFile.default.tmpDir = supybot.directories.data.tmp utils.file.AtomicFile.default.tmpDir = supybot.directories.data.tmp
utils.file.AtomicFile.default.backupDir = supybot.directories.backup utils.file.AtomicFile.default.backupDir = supybot.directories.backup
class PluginDirectories(registry.CommaSeparatedListOfStrings):
def __call__(self):
v = registry.CommaSeparatedListOfStrings.__call__(self)
if _pluginsDir not in v:
v.append(_pluginsDir)
return v
registerGlobalValue(supybot.directories, 'plugins', registerGlobalValue(supybot.directories, 'plugins',
PluginDirectories([], """Determines what directories the bot will registry.CommaSeparatedListOfStrings([], """Determines what directories the
look for plugins in. Accepts a comma-separated list of strings. This bot will look for plugins in. Accepts a comma-separated list of strings.
means that to add another directory, you can nest the former value and add This means that to add another directory, you can nest the former value and
a new one. E.g. you can say: bot: 'config supybot.directories.plugins add a new one. E.g. you can say: bot: 'config supybot.directories.plugins
[config supybot.directories.plugins], newPluginDirectory'.""")) [config supybot.directories.plugins], newPluginDirectory'."""))
registerGlobalValue(supybot, 'plugins', registerGlobalValue(supybot, 'plugins',

View File

@ -38,13 +38,17 @@ import supybot.conf as conf
import supybot.registry as registry import supybot.registry as registry
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
installDir = os.path.dirname(sys.modules[__name__].__file__)
_pluginsDir = os.path.join(installDir, 'plugins')
class Deprecated(ImportError): class Deprecated(ImportError):
pass pass
def loadPluginModule(name, ignoreDeprecation=False): def loadPluginModule(name, ignoreDeprecation=False):
"""Loads (and returns) the module for the plugin with the given name.""" """Loads (and returns) the module for the plugin with the given name."""
files = [] files = []
pluginDirs = conf.supybot.directories.plugins() pluginDirs = conf.supybot.directories.plugins()[:]
pluginDirs.append(_pluginsDir)
for dir in pluginDirs: for dir in pluginDirs:
try: try:
files.extend(os.listdir(dir)) files.extend(os.listdir(dir))