Swapped the order of the arguments for makeChannelFilename.

This commit is contained in:
Jeremy Fincher 2004-09-12 20:26:08 +00:00
parent 4f9e67a796
commit ce3847fc88
8 changed files with 14 additions and 14 deletions

View File

@ -80,7 +80,7 @@ class DbiDunnoDB(object):
def _getDb(self, channel):
# Why cache? It gains very little.
filename = plugins.makeChannelFilename(channel, 'Dunno.db')
filename = plugins.makeChannelFilename('Dunno.db', channel)
self.filenames.add(filename)
return self.DunnoDB(filename)

View File

@ -81,7 +81,7 @@ class DbiFunDBDB(object):
self.dbs[channel] = {}
if type not in self.dbs[channel]:
filename = type.capitalize() + '.db'
filename = plugins.makeChannelFilename(channel, filename)
filename = plugins.makeChannelFilename(filename, channel)
self.filenames.add(filename)
self.dbs[channel][type] = self.FunDBDB(filename)
return self.dbs[channel][type]

View File

@ -82,7 +82,7 @@ conf.registerChannelValue(conf.supybot.plugins.Karma, 'allowUnaddressedKarma',
class SqliteKarmaDB(object):
def _getDb(self, channel):
filename = plugins.makeChannelFilename(channel, 'Karma.db')
filename = plugins.makeChannelFilename('Karma.db', channel)
if os.path.exists(filename):
db = sqlite.connect(filename)
else:

View File

@ -92,7 +92,7 @@ class DbmMarkovDB(object):
def _getDb(self, channel):
if channel not in self.dbs:
# Stupid anydbm seems to append .db to the end of this.
filename = plugins.makeChannelFilename(channel, 'DbmMarkovDB')
filename = plugins.makeChannelFilename('DbmMarkovDB', channel)
# To keep the code simpler for addPair, I decided not to make
# self.dbs[channel]['firsts'] and ['lasts']. Instead, we'll pad
# the words list being sent to addPair such that ['\n \n'] will be

View File

@ -83,7 +83,7 @@ class TrackerDB(dbi.DB):
class ProjectDB(object):
def __init__(self, channel, project):
dir = plugins.makeChannelFilename(channel, 'Projects')
dir = plugins.makeChannelFilename('Projects', channel)
if not os.path.exists(dir):
os.mkdir(dir)
self.projectDir = os.path.join(dir, project)
@ -189,7 +189,7 @@ class ProjectsDB(object):
def projects(self, channel):
"""Returns the projects on channel."""
dir = plugins.makeChannelFilename(channel, 'Projects')
dir = plugins.makeChannelFilename('Projects', channel)
return os.listdir(conf.supybot.directories.data.dirize(dir))
def isProject(self, channel, project):

View File

@ -82,7 +82,7 @@ class QuoteRecord(object):
class SqliteQuotesDB(object):
def _getDb(self, channel):
filename = plugins.makeChannelFilename(channel, 'Quotes.db')
filename = plugins.makeChannelFilename('Quotes.db', channel)
if os.path.exists(filename):
return sqlite.connect(db=filename, mode=0755,
converters={'bool': bool})

View File

@ -91,7 +91,7 @@ conf.registerChannelValue(conf.supybot.plugins.URL, 'nonSnarfingRegexp',
class URLDB(object):
def __init__(self, channel, log):
self.log = log
self.filename = plugins.makeChannelFilename(channel, 'URL.db')
self.filename = plugins.makeChannelFilename('URL.db', channel)
def _getFile(self):
try:

View File

@ -142,12 +142,12 @@ class DBHandler(object):
del self.cachedDb
def makeChannelFilename(channel, filename, dirname=None):
assert ircutils.isChannel(channel), 'channel not a channel, ' \
'the arguments to makeChannelFilename are probably reversed.'
assert filename == os.path.basename(filename), 'We don\'t handle dirs.'
def makeChannelFilename(filename, channel=None, dirname=None):
channel = ircutils.toLower(channel)
if conf.supybot.databases.plugins.channelSpecific.get(channel)():
# ??? This may not be right.
filename = os.path.basename(filename)
if channel is not None and \
conf.get(conf.supybot.databases.plugins.channelSpecific, channel):
if dirname is None:
dir = conf.supybot.directories.data.dirize(channel)
else:
@ -177,7 +177,7 @@ class ChannelDBHandler(object):
"""Override this to specialize the filenames of your databases."""
channel = ircutils.toLower(channel)
className = self.__class__.__name__
return makeChannelFilename(channel, className + self.suffix)
return makeChannelFilename(className + self.suffix, channel)
def makeDb(self, filename):
"""Override this to create your databases."""