From dc93f865db9412b1cd0daa64f1f493c2502d2476 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 15 Nov 2003 04:46:09 +0000 Subject: [PATCH] Changed some maps/filters to imaps/ifilters for efficiency reasons (I was bored, basically). --- plugins/Factoids.py | 5 +++-- plugins/Note.py | 5 +++-- plugins/RSS.py | 3 ++- src/ircdb.py | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/Factoids.py b/plugins/Factoids.py index 75877b968..4fcf46adb 100644 --- a/plugins/Factoids.py +++ b/plugins/Factoids.py @@ -40,6 +40,7 @@ import time import getopt import string import os.path +from itertools import imap import sqlite @@ -102,7 +103,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg): cursor.execute("""INSERT INTO keys VALUES (NULL, %s, 0)""", key) db.commit() cursor.execute("SELECT id, locked FROM keys WHERE key LIKE %s",key) - (id, locked) = map(int, cursor.fetchone()) + (id, locked) = imap(int, cursor.fetchone()) capability = ircdb.makeChannelCapability(channel, 'factoids') if not locked: if not ircdb.checkCapability(msg.prefix, capability): @@ -296,7 +297,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg): if cursor.rowcount == 0: irc.error(msg, 'No factoid matches that key.') return - (id, locked) = map(int, cursor.fetchone()) + (id, locked) = imap(int, cursor.fetchone()) cursor.execute("""SELECT added_by, added_at FROM factoids WHERE key_id=%s ORDER BY id""", id) diff --git a/plugins/Note.py b/plugins/Note.py index 3c7e72322..a54c65944 100644 --- a/plugins/Note.py +++ b/plugins/Note.py @@ -38,6 +38,7 @@ import plugins import time import os.path +from itertools import imap import sqlite @@ -167,7 +168,7 @@ class Note(callbacks.Privmsg): irc.error(msg, s) return (note, toId, fromId, addedAt, public) = cursor.fetchone() - (toId,fromId,addedAt,public) = map(int, (toId,fromId,addedAt,public)) + (toId,fromId,addedAt,public) = imap(int, (toId,fromId,addedAt,public)) elapsed = utils.timeElapsed(time.time() - addedAt) if toId == id: author = ircdb.users.getUser(fromId).name @@ -179,7 +180,7 @@ class Note(callbacks.Privmsg): self.setAsRead(noteid) def _formatNoteData(self, msg, id, fromId, public): - (id, fromId, public) = map(int, (id, fromId, public)) + (id, fromId, public) = imap(int, (id, fromId, public)) if public or not ircutils.isChannel(msg.args[0]): sender = ircdb.users.getUser(fromId).name return '#%s from %s' % (id, sender) diff --git a/plugins/RSS.py b/plugins/RSS.py index 1c952488b..62e4b533c 100644 --- a/plugins/RSS.py +++ b/plugins/RSS.py @@ -37,6 +37,7 @@ module for user-friendliness. import plugins import time +from itertools import imap import rssparser @@ -84,10 +85,10 @@ class RSS(callbacks.Privmsg): feed = self.cachedFeeds[url] headlines = [d['title'].strip().replace('\n', ' ') \ for d in feed['items']] - headlines = map(utils.htmlToText, headlines) if not headlines: irc.error(msg, 'Error grabbing RSS feed') return + headlines = imap(utils.htmlToText, headlines) irc.reply(msg, ' :: '.join(headlines)) def info(self, irc, msg, args): diff --git a/src/ircdb.py b/src/ircdb.py index d6a645aa9..6494f3b3f 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -35,6 +35,7 @@ import os import sets import time import string +from itertools import imap import conf import debug @@ -145,7 +146,7 @@ class CapabilitySet(sets.Set): def __repr__(self): return '%s([%s])' % (self.__class__.__name__, - ', '.join(map(repr, self))) + ', '.join(imap(repr, self))) antiOwner = makeAntiCapability('owner') class UserCapabilitySet(CapabilitySet):