diff --git a/plugins/Dunno.py b/plugins/Dunno.py index 46a2444dd..bbaa816ab 100644 --- a/plugins/Dunno.py +++ b/plugins/Dunno.py @@ -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) diff --git a/plugins/FunDB.py b/plugins/FunDB.py index c5f4c9dd8..9f5c86687 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -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] diff --git a/plugins/Karma.py b/plugins/Karma.py index f8ad61c06..b4269562b 100644 --- a/plugins/Karma.py +++ b/plugins/Karma.py @@ -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: diff --git a/plugins/Markov.py b/plugins/Markov.py index aed254726..482e105a8 100644 --- a/plugins/Markov.py +++ b/plugins/Markov.py @@ -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 diff --git a/plugins/Project.py b/plugins/Project.py index 58e95ec2b..0aa32c2ec 100644 --- a/plugins/Project.py +++ b/plugins/Project.py @@ -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): diff --git a/plugins/Quotes.py b/plugins/Quotes.py index 083272811..8ba1b71c5 100644 --- a/plugins/Quotes.py +++ b/plugins/Quotes.py @@ -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}) diff --git a/plugins/URL.py b/plugins/URL.py index 5e7801bb2..052fe0161 100644 --- a/plugins/URL.py +++ b/plugins/URL.py @@ -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: diff --git a/plugins/__init__.py b/plugins/__init__.py index b3d6f01e1..cf3236e18 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -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."""