Changed ChannelUserDatabase to ChannelUserDB.

This commit is contained in:
Jeremy Fincher 2004-02-07 21:36:40 +00:00
parent 18fcfd9335
commit 6072094207
3 changed files with 10 additions and 4 deletions

View File

@ -52,7 +52,7 @@ import callbacks
filename = os.path.join(conf.supybot.directories.data(), 'Herald.db')
class HeraldDB(plugins.ChannelUserDatabase):
class HeraldDB(plugins.ChannelUserDB):
def serialize(self, v):
return [v]

View File

@ -57,7 +57,7 @@ import privmsgs
import registry
import callbacks
class SeenDB(plugins.ChannelUserDatabase):
class SeenDB(plugins.ChannelUserDB):
def serialize(self, v):
return list(v)

View File

@ -187,7 +187,7 @@ class ChannelUserDictionary(UserDict.DictMixin):
return L
class ChannelUserDatabase(ChannelUserDictionary):
class ChannelUserDB(ChannelUserDictionary):
def __init__(self, filename):
ChannelUserDictionary.__init__(self)
self.filename = filename
@ -204,15 +204,21 @@ class ChannelUserDatabase(ChannelUserDictionary):
try:
channel = t.pop(0)
id = t.pop(0)
id = int(id)
try:
id = int(id)
except ValueError:
# We'll skip over this so, say, nicks can be kept here.
pass
v = self.deserialize(t)
self[channel, id] = v
except Exception, e:
log.warning('Invalid line #%s in %s.',
lineno, self.__class__.__name__)
log.debug('Exception: %s', utils.exnToString(e))
except Exception, e: # This catches exceptions from csv.reader.
log.warning('Invalid line #%s in %s.',
lineno, self.__class__.__name__)
log.debug('Exception: %s', utils.exnToString(e))
def flush(self):
fd = file(self.filename, 'w')