mirror of
https://github.com/progval/Limnoria.git
synced 2025-05-04 09:21:07 -05:00
Swapped the order of the arguments for makeChannelFilename.
This commit is contained in:
parent
4f9e67a796
commit
ce3847fc88
@ -80,7 +80,7 @@ class DbiDunnoDB(object):
|
|||||||
|
|
||||||
def _getDb(self, channel):
|
def _getDb(self, channel):
|
||||||
# Why cache? It gains very little.
|
# Why cache? It gains very little.
|
||||||
filename = plugins.makeChannelFilename(channel, 'Dunno.db')
|
filename = plugins.makeChannelFilename('Dunno.db', channel)
|
||||||
self.filenames.add(filename)
|
self.filenames.add(filename)
|
||||||
return self.DunnoDB(filename)
|
return self.DunnoDB(filename)
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class DbiFunDBDB(object):
|
|||||||
self.dbs[channel] = {}
|
self.dbs[channel] = {}
|
||||||
if type not in self.dbs[channel]:
|
if type not in self.dbs[channel]:
|
||||||
filename = type.capitalize() + '.db'
|
filename = type.capitalize() + '.db'
|
||||||
filename = plugins.makeChannelFilename(channel, filename)
|
filename = plugins.makeChannelFilename(filename, channel)
|
||||||
self.filenames.add(filename)
|
self.filenames.add(filename)
|
||||||
self.dbs[channel][type] = self.FunDBDB(filename)
|
self.dbs[channel][type] = self.FunDBDB(filename)
|
||||||
return self.dbs[channel][type]
|
return self.dbs[channel][type]
|
||||||
|
@ -82,7 +82,7 @@ conf.registerChannelValue(conf.supybot.plugins.Karma, 'allowUnaddressedKarma',
|
|||||||
|
|
||||||
class SqliteKarmaDB(object):
|
class SqliteKarmaDB(object):
|
||||||
def _getDb(self, channel):
|
def _getDb(self, channel):
|
||||||
filename = plugins.makeChannelFilename(channel, 'Karma.db')
|
filename = plugins.makeChannelFilename('Karma.db', channel)
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
db = sqlite.connect(filename)
|
db = sqlite.connect(filename)
|
||||||
else:
|
else:
|
||||||
|
@ -92,7 +92,7 @@ class DbmMarkovDB(object):
|
|||||||
def _getDb(self, channel):
|
def _getDb(self, channel):
|
||||||
if channel not in self.dbs:
|
if channel not in self.dbs:
|
||||||
# Stupid anydbm seems to append .db to the end of this.
|
# 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
|
# To keep the code simpler for addPair, I decided not to make
|
||||||
# self.dbs[channel]['firsts'] and ['lasts']. Instead, we'll pad
|
# self.dbs[channel]['firsts'] and ['lasts']. Instead, we'll pad
|
||||||
# the words list being sent to addPair such that ['\n \n'] will be
|
# the words list being sent to addPair such that ['\n \n'] will be
|
||||||
|
@ -83,7 +83,7 @@ class TrackerDB(dbi.DB):
|
|||||||
|
|
||||||
class ProjectDB(object):
|
class ProjectDB(object):
|
||||||
def __init__(self, channel, project):
|
def __init__(self, channel, project):
|
||||||
dir = plugins.makeChannelFilename(channel, 'Projects')
|
dir = plugins.makeChannelFilename('Projects', channel)
|
||||||
if not os.path.exists(dir):
|
if not os.path.exists(dir):
|
||||||
os.mkdir(dir)
|
os.mkdir(dir)
|
||||||
self.projectDir = os.path.join(dir, project)
|
self.projectDir = os.path.join(dir, project)
|
||||||
@ -189,7 +189,7 @@ class ProjectsDB(object):
|
|||||||
|
|
||||||
def projects(self, channel):
|
def projects(self, channel):
|
||||||
"""Returns the projects on 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))
|
return os.listdir(conf.supybot.directories.data.dirize(dir))
|
||||||
|
|
||||||
def isProject(self, channel, project):
|
def isProject(self, channel, project):
|
||||||
|
@ -82,7 +82,7 @@ class QuoteRecord(object):
|
|||||||
|
|
||||||
class SqliteQuotesDB(object):
|
class SqliteQuotesDB(object):
|
||||||
def _getDb(self, channel):
|
def _getDb(self, channel):
|
||||||
filename = plugins.makeChannelFilename(channel, 'Quotes.db')
|
filename = plugins.makeChannelFilename('Quotes.db', channel)
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
return sqlite.connect(db=filename, mode=0755,
|
return sqlite.connect(db=filename, mode=0755,
|
||||||
converters={'bool': bool})
|
converters={'bool': bool})
|
||||||
|
@ -91,7 +91,7 @@ conf.registerChannelValue(conf.supybot.plugins.URL, 'nonSnarfingRegexp',
|
|||||||
class URLDB(object):
|
class URLDB(object):
|
||||||
def __init__(self, channel, log):
|
def __init__(self, channel, log):
|
||||||
self.log = log
|
self.log = log
|
||||||
self.filename = plugins.makeChannelFilename(channel, 'URL.db')
|
self.filename = plugins.makeChannelFilename('URL.db', channel)
|
||||||
|
|
||||||
def _getFile(self):
|
def _getFile(self):
|
||||||
try:
|
try:
|
||||||
|
@ -142,12 +142,12 @@ class DBHandler(object):
|
|||||||
del self.cachedDb
|
del self.cachedDb
|
||||||
|
|
||||||
|
|
||||||
def makeChannelFilename(channel, filename, dirname=None):
|
def makeChannelFilename(filename, channel=None, 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.'
|
|
||||||
channel = ircutils.toLower(channel)
|
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:
|
if dirname is None:
|
||||||
dir = conf.supybot.directories.data.dirize(channel)
|
dir = conf.supybot.directories.data.dirize(channel)
|
||||||
else:
|
else:
|
||||||
@ -177,7 +177,7 @@ class ChannelDBHandler(object):
|
|||||||
"""Override this to specialize the filenames of your databases."""
|
"""Override this to specialize the filenames of your databases."""
|
||||||
channel = ircutils.toLower(channel)
|
channel = ircutils.toLower(channel)
|
||||||
className = self.__class__.__name__
|
className = self.__class__.__name__
|
||||||
return makeChannelFilename(channel, className + self.suffix)
|
return makeChannelFilename(className + self.suffix, channel)
|
||||||
|
|
||||||
def makeDb(self, filename):
|
def makeDb(self, filename):
|
||||||
"""Override this to create your databases."""
|
"""Override this to create your databases."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user