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
1 changed files with 8 additions and 7 deletions

View File

@ -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