diff --git a/plugins/__init__.py b/plugins/__init__.py index 6be678777..4643840b9 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -109,20 +109,21 @@ class DBHandler(object): self.cachedDb.die() del self.cachedDb -def makeChannelFilename(channel, filename): - # XXX We should put channel stuff in its own directory. + +def makeChannelFilename(channel, filename, dirname=None): assert filename == os.path.basename(filename), 'We don\'t handle dirs.' channel = ircutils.toLower(channel) if conf.supybot.databases.plugins.channelSpecific.get(channel)(): - # Should we offer the old #channel-filename naming scheme? - dir = conf.supybot.directories.data.dirize(channel) + if dirname is None: + dir = conf.supybot.directories.data.dirize(channel) + else: + dir = os.path.join(dirname, channel) if not os.path.exists(dir): - os.mkdir(dir) + os.makedirs(dir) return os.path.join(dir, filename) else: return conf.supybot.directories.data.dirize(filename) -## filename = '%s-%s' % (channel, filename) -## return conf.supybot.directories.data.dirize(filename) + # XXX: This shouldn't be a mixin. This should be contained by classes that # want such behavior. But at this point, it wouldn't gain much for us