From 60720942077adf80f3c86a4eaa8cb484af20f70a Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 7 Feb 2004 21:36:40 +0000 Subject: [PATCH] Changed ChannelUserDatabase to ChannelUserDB. --- plugins/Herald.py | 2 +- plugins/Seen.py | 2 +- src/plugins.py | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/Herald.py b/plugins/Herald.py index d97ce7883..47a6825e0 100644 --- a/plugins/Herald.py +++ b/plugins/Herald.py @@ -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] diff --git a/plugins/Seen.py b/plugins/Seen.py index 242a7bfc5..5b9c16940 100644 --- a/plugins/Seen.py +++ b/plugins/Seen.py @@ -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) diff --git a/src/plugins.py b/src/plugins.py index c03925dde..d2e3f7648 100644 --- a/src/plugins.py +++ b/src/plugins.py @@ -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')