Todo #1047143, conversion of os.path.join calls to dirize calls.

This commit is contained in:
Jeremy Fincher 2004-12-16 07:43:13 +00:00
parent eb03f94f07
commit 161b9b96fc
10 changed files with 27 additions and 32 deletions

View File

@ -151,7 +151,6 @@ def makeNewAlias(name, alias):
conf.registerPlugin('Alias') conf.registerPlugin('Alias')
conf.registerGroup(conf.supybot.plugins.Alias, 'aliases') conf.registerGroup(conf.supybot.plugins.Alias, 'aliases')
filename = os.path.join(conf.supybot.directories.conf(), 'aliases.conf')
class Alias(callbacks.Privmsg): class Alias(callbacks.Privmsg):
def __init__(self): def __init__(self):
callbacks.Privmsg.__init__(self) callbacks.Privmsg.__init__(self)

View File

@ -168,8 +168,7 @@ class ChannelLogger(callbacks.Privmsg):
return '%s.log' % channel return '%s.log' % channel
def getLogDir(self, irc, channel): def getLogDir(self, irc, channel):
logDir = conf.supybot.directories.log() logDir = conf.supybot.directories.log.dirize(self.name())
logDir = os.path.join(logDir, self.name())
if self.registryValue('directories'): if self.registryValue('directories'):
if self.registryValue('directories.network'): if self.registryValue('directories.network'):
logDir = os.path.join(logDir, irc.network) logDir = os.path.join(logDir, irc.network)

View File

@ -192,6 +192,7 @@ class StatsDB(plugins.ChannelUserDB):
def getUserStats(self, channel, id): def getUserStats(self, channel, id):
return self[channel, id] return self[channel, id]
filename = conf.supybot.directories.data.dirize('ChannelStats.db')
class ChannelStats(callbacks.Privmsg): class ChannelStats(callbacks.Privmsg):
noIgnore = True noIgnore = True
def __init__(self): def __init__(self):
@ -199,15 +200,12 @@ class ChannelStats(callbacks.Privmsg):
self.lastmsg = None self.lastmsg = None
self.laststate = None self.laststate = None
self.outFiltering = False self.outFiltering = False
self.db = StatsDB(os.path.join(conf.supybot.directories.data(), self.db = StatsDB(filename)
'ChannelStats.db')) self._flush = self.db.flush
world.flushers.append(self.db.flush) world.flushers.append(self._flush)
def die(self): def die(self):
if self.db.flush in world.flushers: world.flushers.remove(self._flush)
world.flushers.remove(self.db.flush)
else:
self.log.debug('Odd, no flush in flushers: %r', world.flushers)
self.db.close() self.db.close()
callbacks.Privmsg.die(self) callbacks.Privmsg.die(self)

View File

@ -102,7 +102,7 @@ class Debian(callbacks.Privmsg,
'debian/dists/unstable/Contents-i386.gz', 'debian/dists/unstable/Contents-i386.gz',
604800, None) 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): def __init__(self):
callbacks.Privmsg.__init__(self) callbacks.Privmsg.__init__(self)
plugins.PeriodicFileDownloader.__init__(self) plugins.PeriodicFileDownloader.__init__(self)

View File

@ -50,7 +50,7 @@ import supybot.ircutils as ircutils
import supybot.registry as registry import supybot.registry as registry
import supybot.callbacks as callbacks 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): class HeraldDB(plugins.ChannelUserDB):
def serialize(self, v): def serialize(self, v):

View File

@ -312,8 +312,7 @@ class Lookup(callbacks.Privmsg):
group.unregister(name) group.unregister(name)
def addDatabase(self, name, filename): def addDatabase(self, name, filename):
dataDir = conf.supybot.directories.data() filename = conf.supybot.directories.data.dirize(filename)
filename = os.path.join(dataDir, filename)
fd = file(filename) fd = file(filename)
self.db.addLookup(name, fd, self._splitRe) self.db.addLookup(name, fd, self._splitRe)

View File

@ -45,9 +45,13 @@ import supybot.irclib as irclib
### ###
class RawLogger(irclib.IrcCallback): class RawLogger(irclib.IrcCallback):
def __init__(self): def __init__(self):
logDir = conf.supybot.directories.log() self.fd = file(conf.supybot.directories.log.dirize('raw.log'), 'a')
self.fd = file(os.path.join(logDir, 'raw.log'), 'a') self._flush = self.fd.flush
world.flushers.append(self.fd.flush) world.flushers.append(self._flush)
def die(self):
world.flushers.remove(self._flush)
self.fd.close()
def inFilter(self, irc, msg): def inFilter(self, irc, msg):
self.fd.write(str(msg)) self.fd.write(str(msg))

View File

@ -76,11 +76,12 @@ class TodoDB(plugins.DBHandler):
return db return db
filename = conf.supybot.directories.data.dirize('Todo.db')
class Todo(callbacks.Privmsg): class Todo(callbacks.Privmsg):
def __init__(self): def __init__(self):
callbacks.Privmsg.__init__(self) callbacks.Privmsg.__init__(self)
dataDir = conf.supybot.directories.data() dataDir = conf.supybot.directories.data()
self.dbHandler = TodoDB(os.path.join(dataDir, 'Todo')) self.dbHandler = TodoDB(filename)
def die(self): def die(self):
self.dbHandler.die() self.dbHandler.die()

View File

@ -172,7 +172,7 @@ class WordStatsDB(plugins.ChannelUserDB):
self[channel, id][word] += 1 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): class WordStats(callbacks.Privmsg):
noIgnore = True noIgnore = True
def __init__(self): def __init__(self):
@ -180,11 +180,11 @@ class WordStats(callbacks.Privmsg):
self.__parent.__init__() self.__parent.__init__()
self.db = WordStatsDB(filename) self.db = WordStatsDB(filename)
self.queried = False self.queried = False
world.flushers.append(self.db.flush) self._flush = self.db.flush
world.flushers.append(self._flush)
def die(self): def die(self):
if self.db.flush in world.flushers: world.flushers.remove(self._flush)
world.flushers.remove(self.db.flush)
self.db.close() self.db.close()
self.__parent.die() self.__parent.die()

View File

@ -69,18 +69,13 @@ def configure(advanced):
class XMLLogger(callbacks.Privmsg): class XMLLogger(callbacks.Privmsg):
def __init__(self): def __init__(self):
callbacks.Privmsg.__init__(self) callbacks.Privmsg.__init__(self)
logDir = conf.supybot.directories.log() filename = conf.supybot.directories.log.dirize('xml.log')
self.fd = file(os.path.join(logDir, 'xml.log'), 'a') self.fd = file(filename, 'a')
self.boundFlushMethod = self.fd.flush self._flush = self.fd.flush
world.flushers.append(self.boundFlushMethod) world.flushers.append(self._flush)
def die(self): def die(self):
if self.boundFlushMethod in world.flushers: world.flushers.remove(self._flush)
world.flushers.remove(self.boundFlushMethod)
else:
if not world.dying:
self.log.warning('My flusher wasn\'t in world.flushers: %r',
world.flushers)
self.fd.close() self.fd.close()
def writeMsg(self, msg): def writeMsg(self, msg):