diff --git a/plugins/Alias.py b/plugins/Alias.py index e401c06a9..73f9772aa 100644 --- a/plugins/Alias.py +++ b/plugins/Alias.py @@ -151,7 +151,6 @@ def makeNewAlias(name, alias): conf.registerPlugin('Alias') conf.registerGroup(conf.supybot.plugins.Alias, 'aliases') -filename = os.path.join(conf.supybot.directories.conf(), 'aliases.conf') class Alias(callbacks.Privmsg): def __init__(self): callbacks.Privmsg.__init__(self) diff --git a/plugins/ChannelLogger.py b/plugins/ChannelLogger.py index ef2423cb5..3ba1074c4 100644 --- a/plugins/ChannelLogger.py +++ b/plugins/ChannelLogger.py @@ -168,8 +168,7 @@ class ChannelLogger(callbacks.Privmsg): return '%s.log' % channel def getLogDir(self, irc, channel): - logDir = conf.supybot.directories.log() - logDir = os.path.join(logDir, self.name()) + logDir = conf.supybot.directories.log.dirize(self.name()) if self.registryValue('directories'): if self.registryValue('directories.network'): logDir = os.path.join(logDir, irc.network) diff --git a/plugins/ChannelStats.py b/plugins/ChannelStats.py index 2bf7140c0..407b2a8e9 100644 --- a/plugins/ChannelStats.py +++ b/plugins/ChannelStats.py @@ -192,6 +192,7 @@ class StatsDB(plugins.ChannelUserDB): def getUserStats(self, channel, id): return self[channel, id] +filename = conf.supybot.directories.data.dirize('ChannelStats.db') class ChannelStats(callbacks.Privmsg): noIgnore = True def __init__(self): @@ -199,15 +200,12 @@ class ChannelStats(callbacks.Privmsg): self.lastmsg = None self.laststate = None self.outFiltering = False - self.db = StatsDB(os.path.join(conf.supybot.directories.data(), - 'ChannelStats.db')) - world.flushers.append(self.db.flush) + self.db = StatsDB(filename) + self._flush = self.db.flush + world.flushers.append(self._flush) def die(self): - if self.db.flush in world.flushers: - world.flushers.remove(self.db.flush) - else: - self.log.debug('Odd, no flush in flushers: %r', world.flushers) + world.flushers.remove(self._flush) self.db.close() callbacks.Privmsg.die(self) diff --git a/plugins/Debian.py b/plugins/Debian.py index c2492ddc7..c5663636f 100644 --- a/plugins/Debian.py +++ b/plugins/Debian.py @@ -102,7 +102,7 @@ class Debian(callbacks.Privmsg, 'debian/dists/unstable/Contents-i386.gz', 604800, None) } - contents = os.path.join(conf.supybot.directories.data(),'Contents-i386.gz') + contents = conf.supybot.directories.data.dirize('Contents-i386.gz') def __init__(self): callbacks.Privmsg.__init__(self) plugins.PeriodicFileDownloader.__init__(self) diff --git a/plugins/Herald.py b/plugins/Herald.py index ea100d7b6..0d44b0a6d 100644 --- a/plugins/Herald.py +++ b/plugins/Herald.py @@ -50,7 +50,7 @@ import supybot.ircutils as ircutils import supybot.registry as registry import supybot.callbacks as callbacks -filename = os.path.join(conf.supybot.directories.data(), 'Herald.db') +filename = conf.supybot.directories.data.dirize('Herald.db') class HeraldDB(plugins.ChannelUserDB): def serialize(self, v): diff --git a/plugins/Lookup.py b/plugins/Lookup.py index ba2f9f738..a6e6358c5 100644 --- a/plugins/Lookup.py +++ b/plugins/Lookup.py @@ -312,8 +312,7 @@ class Lookup(callbacks.Privmsg): group.unregister(name) def addDatabase(self, name, filename): - dataDir = conf.supybot.directories.data() - filename = os.path.join(dataDir, filename) + filename = conf.supybot.directories.data.dirize(filename) fd = file(filename) self.db.addLookup(name, fd, self._splitRe) diff --git a/plugins/RawLogger.py b/plugins/RawLogger.py index a2e831729..5f686fe07 100644 --- a/plugins/RawLogger.py +++ b/plugins/RawLogger.py @@ -45,10 +45,14 @@ import supybot.irclib as irclib ### class RawLogger(irclib.IrcCallback): def __init__(self): - logDir = conf.supybot.directories.log() - self.fd = file(os.path.join(logDir, 'raw.log'), 'a') - world.flushers.append(self.fd.flush) + self.fd = file(conf.supybot.directories.log.dirize('raw.log'), 'a') + self._flush = self.fd.flush + world.flushers.append(self._flush) + def die(self): + world.flushers.remove(self._flush) + self.fd.close() + def inFilter(self, irc, msg): self.fd.write(str(msg)) return msg diff --git a/plugins/Todo.py b/plugins/Todo.py index 36008e68b..9888dd7cd 100644 --- a/plugins/Todo.py +++ b/plugins/Todo.py @@ -76,11 +76,12 @@ class TodoDB(plugins.DBHandler): return db +filename = conf.supybot.directories.data.dirize('Todo.db') class Todo(callbacks.Privmsg): def __init__(self): callbacks.Privmsg.__init__(self) dataDir = conf.supybot.directories.data() - self.dbHandler = TodoDB(os.path.join(dataDir, 'Todo')) + self.dbHandler = TodoDB(filename) def die(self): self.dbHandler.die() diff --git a/plugins/WordStats.py b/plugins/WordStats.py index 23f228687..417890279 100644 --- a/plugins/WordStats.py +++ b/plugins/WordStats.py @@ -172,7 +172,7 @@ class WordStatsDB(plugins.ChannelUserDB): self[channel, id][word] += 1 -filename=os.path.join(conf.supybot.directories.data(), 'WordStats.db') +filename = conf.supybot.directories.data.dirize('WordStats.db') class WordStats(callbacks.Privmsg): noIgnore = True def __init__(self): @@ -180,11 +180,11 @@ class WordStats(callbacks.Privmsg): self.__parent.__init__() self.db = WordStatsDB(filename) self.queried = False - world.flushers.append(self.db.flush) + self._flush = self.db.flush + world.flushers.append(self._flush) def die(self): - if self.db.flush in world.flushers: - world.flushers.remove(self.db.flush) + world.flushers.remove(self._flush) self.db.close() self.__parent.die() diff --git a/plugins/XMLLogger.py b/plugins/XMLLogger.py index 8677bab2d..0457f175a 100644 --- a/plugins/XMLLogger.py +++ b/plugins/XMLLogger.py @@ -69,18 +69,13 @@ def configure(advanced): class XMLLogger(callbacks.Privmsg): def __init__(self): callbacks.Privmsg.__init__(self) - logDir = conf.supybot.directories.log() - self.fd = file(os.path.join(logDir, 'xml.log'), 'a') - self.boundFlushMethod = self.fd.flush - world.flushers.append(self.boundFlushMethod) + filename = conf.supybot.directories.log.dirize('xml.log') + self.fd = file(filename, 'a') + self._flush = self.fd.flush + world.flushers.append(self._flush) def die(self): - if self.boundFlushMethod in world.flushers: - world.flushers.remove(self.boundFlushMethod) - else: - if not world.dying: - self.log.warning('My flusher wasn\'t in world.flushers: %r', - world.flushers) + world.flushers.remove(self._flush) self.fd.close() def writeMsg(self, msg):