From 6986fc7abe4c7833c328bada8f45dc32eb9d2a64 Mon Sep 17 00:00:00 2001 From: James Vega Date: Thu, 12 Mar 2009 14:50:46 -0400 Subject: [PATCH] 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 --- src/conf.py | 18 ++++-------------- src/plugin.py | 6 +++++- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/conf.py b/src/conf.py index e45d15fbb..5bcdc9c08 100644 --- a/src/conf.py +++ b/src/conf.py @@ -37,9 +37,6 @@ import supybot.utils as utils import supybot.registry as registry 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. ### @@ -737,18 +734,11 @@ registerGlobalValue(supybot.directories.data, 'tmp', utils.file.AtomicFile.default.tmpDir = supybot.directories.data.tmp 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', - PluginDirectories([], """Determines what directories the bot will - look for plugins in. Accepts a comma-separated list of strings. This - means that to add another directory, you can nest the former value and add - a new one. E.g. you can say: bot: 'config supybot.directories.plugins + registry.CommaSeparatedListOfStrings([], """Determines what directories the + bot will look for plugins in. Accepts a comma-separated list of strings. + This means that to add another directory, you can nest the former value and + add a new one. E.g. you can say: bot: 'config supybot.directories.plugins [config supybot.directories.plugins], newPluginDirectory'.""")) registerGlobalValue(supybot, 'plugins', diff --git a/src/plugin.py b/src/plugin.py index 4cc59f990..25cbe67a7 100644 --- a/src/plugin.py +++ b/src/plugin.py @@ -38,13 +38,17 @@ import supybot.conf as conf import supybot.registry as registry import supybot.callbacks as callbacks +installDir = os.path.dirname(sys.modules[__name__].__file__) +_pluginsDir = os.path.join(installDir, 'plugins') + class Deprecated(ImportError): pass def loadPluginModule(name, ignoreDeprecation=False): """Loads (and returns) the module for the plugin with the given name.""" files = [] - pluginDirs = conf.supybot.directories.plugins() + pluginDirs = conf.supybot.directories.plugins()[:] + pluginDirs.append(_pluginsDir) for dir in pluginDirs: try: files.extend(os.listdir(dir))