Updated to allow a dirname, so I can use it later for ChannelLogger.

This commit is contained in:
Jeremy Fincher 2004-08-06 11:29:51 +00:00
parent 542a9a8193
commit 3a916b2486

View File

@ -109,20 +109,21 @@ class DBHandler(object):
self.cachedDb.die() self.cachedDb.die()
del self.cachedDb 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.' assert filename == os.path.basename(filename), 'We don\'t handle dirs.'
channel = ircutils.toLower(channel) channel = ircutils.toLower(channel)
if conf.supybot.databases.plugins.channelSpecific.get(channel)(): if conf.supybot.databases.plugins.channelSpecific.get(channel)():
# Should we offer the old #channel-filename naming scheme? if dirname is None:
dir = conf.supybot.directories.data.dirize(channel) dir = conf.supybot.directories.data.dirize(channel)
else:
dir = os.path.join(dirname, channel)
if not os.path.exists(dir): if not os.path.exists(dir):
os.mkdir(dir) os.makedirs(dir)
return os.path.join(dir, filename) return os.path.join(dir, filename)
else: else:
return conf.supybot.directories.data.dirize(filename) 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 # 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 # want such behavior. But at this point, it wouldn't gain much for us